Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Commands/HttpServerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion src/HttpServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

Expand Down