Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 29c6bfa

Browse files
authoredSep 10, 2021
Merge pull request #503 from memfork/fix-task-worker-for-queue
Fix: task worker num output zero always and enable task worker when defined connections in queue.php
2 parents 4c5fe33 + 51fae3a commit 29c6bfa

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed
 

‎src/Commands/HttpServerCommand.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,21 @@ protected function showInfos()
219219
$workerNum = Arr::get($this->config, 'server.options.worker_num');
220220
$taskWorkerNum = Arr::get($this->config, 'server.options.task_worker_num');
221221
$isWebsocket = Arr::get($this->config, 'websocket.enabled');
222-
$hasTaskWorker = $isWebsocket || Arr::get($this->config, 'queue.default') === 'swoole';
222+
223+
$queueConfig = $this->laravel->make('config')->get('queue');
224+
225+
// lookup for set swoole driver
226+
$isDefinedSwooleDriver = in_array(
227+
'swoole',
228+
array_column(
229+
$queueConfig['connections'] ?? [],
230+
'driver'
231+
),
232+
true
233+
) || ($queueConfig['default'] ?? null) === 'swoole';
234+
235+
$hasTaskWorker = $isWebsocket || $isDefinedSwooleDriver;
236+
223237
$logFile = Arr::get($this->config, 'server.options.log_file');
224238
$pids = $this->laravel->make(PidManager::class)->read();
225239
$masterPid = $pids['masterPid'] ?? null;

‎src/HttpServiceProvider.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,18 @@ protected function configureSwooleServer()
181181
$config = $this->app->make('config');
182182
$options = $config->get('swoole_http.server.options');
183183

184+
// lookup for set swoole driver
185+
$isDefinedSwooleDriver = in_array(
186+
'swoole',
187+
array_column(
188+
$config->get('queue.connections'),
189+
'driver'
190+
),
191+
true
192+
) || $config->get('queue.default') === 'swoole';
193+
184194
// only enable task worker in websocket mode and for queue driver
185-
if ($config->get('queue.default') !== 'swoole' && ! $this->isWebsocket) {
195+
if (! $isDefinedSwooleDriver && ! $this->isWebsocket) {
186196
unset($options['task_worker_num']);
187197
}
188198

0 commit comments

Comments
 (0)
This repository has been archived.