diff --git a/src/Commands/HttpServerCommand.php b/src/Commands/HttpServerCommand.php index df9e004..ff074a5 100644 --- a/src/Commands/HttpServerCommand.php +++ b/src/Commands/HttpServerCommand.php @@ -219,7 +219,21 @@ protected function showInfos() $workerNum = Arr::get($this->config, 'server.options.worker_num'); $taskWorkerNum = Arr::get($this->config, 'server.options.task_worker_num'); $isWebsocket = Arr::get($this->config, 'websocket.enabled'); - $hasTaskWorker = $isWebsocket || Arr::get($this->config, 'queue.default') === 'swoole'; + + $queueConfig = $this->laravel->make('config')->get('queue'); + + // lookup for set swoole driver + $isDefinedSwooleDriver = in_array( + 'swoole', + array_column( + $queueConfig['connections'] ?? [], + 'driver' + ), + true + ) || ($queueConfig['default'] ?? null) === 'swoole'; + + $hasTaskWorker = $isWebsocket || $isDefinedSwooleDriver; + $logFile = Arr::get($this->config, 'server.options.log_file'); $pids = $this->laravel->make(PidManager::class)->read(); $masterPid = $pids['masterPid'] ?? null; diff --git a/src/HttpServiceProvider.php b/src/HttpServiceProvider.php index fdc7460..cf8307a 100644 --- a/src/HttpServiceProvider.php +++ b/src/HttpServiceProvider.php @@ -181,8 +181,18 @@ protected function configureSwooleServer() $config = $this->app->make('config'); $options = $config->get('swoole_http.server.options'); + // lookup for set swoole driver + $isDefinedSwooleDriver = in_array( + 'swoole', + array_column( + $config->get('queue.connections'), + 'driver' + ), + true + ) || $config->get('queue.default') === 'swoole'; + // only enable task worker in websocket mode and for queue driver - if ($config->get('queue.default') !== 'swoole' && ! $this->isWebsocket) { + if (! $isDefinedSwooleDriver && ! $this->isWebsocket) { unset($options['task_worker_num']); }