From f30bc148e05fb6aeb7337320ad16e269edf0c066 Mon Sep 17 00:00:00 2001 From: Arif Hoque Date: Thu, 22 Jan 2026 17:23:17 +0600 Subject: [PATCH] default queue worker timeout 3600 seconds to unlimited --- src/Commands/QueueRunCommand.php | 18 +++++++++++++----- src/QueueWorker.php | 6 +++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Commands/QueueRunCommand.php b/src/Commands/QueueRunCommand.php index 1362c6c..0e7af03 100644 --- a/src/Commands/QueueRunCommand.php +++ b/src/Commands/QueueRunCommand.php @@ -13,7 +13,7 @@ class QueueRunCommand extends Command * * @var string */ - protected $name = 'queue:run {--queue=default} {--sleep=3} {--memory=128} {--timeout=3600} {--limit=}'; + protected $name = 'queue:run {--queue=default} {--sleep=3} {--memory=128} {--timeout=0} {--limit=}'; /** * The command description. @@ -50,7 +50,7 @@ public function __construct(QueueManager $manager) /** * Execute the console command. - * Example: php pool queue:run --queue=reports --sleep=10 --memory=1024 --timeout=3600 --limit= + * Example: php pool queue:run --queue=reports --sleep=10 --memory=1024 --timeout=0 --limit= * * @return int */ @@ -60,13 +60,21 @@ protected function handle(): int $queue = $this->option('queue', 'default'); $sleep = (int) $this->option('sleep', 3); $maxMemory = (int) $this->option('memory', 128); - $maxTime = (int) $this->option('timeout', 3600); - $maxLimit = $this->option('limit'); + $maxTimeInput = $this->option('timeout'); + $maxTime = $maxTimeInput !== 0 ? (int) $maxTimeInput : -1; + + $maxLimit = $this->option('limit'); $maxLimit = $maxLimit !== null ? (int) $maxLimit : null; $this->displaySuccess("Starting queue worker on queue: {$queue}"); - $configInfo = "Configuration: sleep={$sleep}s, memory={$maxMemory}MB, timeout={$maxTime}s"; + $configInfo = "Configuration: sleep={$sleep}s, memory={$maxMemory}MB, timeout="; + + if ($maxTime > 0) { + $configInfo .= "{$maxTime}s"; + } else { + $configInfo .= "unlimited"; + } if (!empty($maxLimit)) { $configInfo .= ", limit={$maxLimit} jobs"; diff --git a/src/QueueWorker.php b/src/QueueWorker.php index af3566a..3eb4518 100644 --- a/src/QueueWorker.php +++ b/src/QueueWorker.php @@ -27,7 +27,7 @@ class QueueWorker * * @var int */ - protected $maxExecutionTime = 3600; + protected $maxExecutionTime = 0; /** * The number of seconds to wait before polling the queue. @@ -453,6 +453,10 @@ protected function memoryExceeded(): bool */ protected function timeExceeded(int $startTime): bool { + if ($this->maxExecutionTime <= 0) { + return false; + } + return (time() - $startTime) >= $this->maxExecutionTime; }