diff --git a/src/Illuminate/Queue/Console/PauseCommand.php b/src/Illuminate/Queue/Console/PauseCommand.php index 8b18c23ee621..ae264f01367c 100644 --- a/src/Illuminate/Queue/Console/PauseCommand.php +++ b/src/Illuminate/Queue/Console/PauseCommand.php @@ -5,6 +5,7 @@ use Illuminate\Console\Command; use Illuminate\Contracts\Queue\Factory as QueueManager; use Illuminate\Queue\Console\Concerns\ParsesQueue; +use Illuminate\Queue\Worker; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'queue:pause')] @@ -33,6 +34,12 @@ class PauseCommand extends Command */ public function handle(QueueManager $manager) { + if (! Worker::$pausable) { + $this->components->error('Worker::$pausable must be set to true to use this command.'); + + return 1; + } + [$connection, $queue] = $this->parseQueue($this->argument('queue')); $manager->pause($connection, $queue); diff --git a/src/Illuminate/Queue/Console/RestartCommand.php b/src/Illuminate/Queue/Console/RestartCommand.php index 892380682528..79667b274a3a 100644 --- a/src/Illuminate/Queue/Console/RestartCommand.php +++ b/src/Illuminate/Queue/Console/RestartCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Command; use Illuminate\Contracts\Cache\Repository as Cache; +use Illuminate\Queue\Worker; use Illuminate\Support\InteractsWithTime; use Symfony\Component\Console\Attribute\AsCommand; @@ -48,12 +49,20 @@ public function __construct(Cache $cache) /** * Execute the console command. * - * @return void + * @return int */ public function handle() { + if (! Worker::$restartable) { + $this->components->error('Worker::$restartable must be set to true to use this command.'); + + return self::FAILURE; + } + $this->cache->forever('illuminate:queue:restart', $this->currentTime()); $this->components->info('Broadcasting queue restart signal.'); + + return self::SUCCESS; } } diff --git a/src/Illuminate/Queue/Console/ResumeCommand.php b/src/Illuminate/Queue/Console/ResumeCommand.php index 67a0ac69293b..48b1f7d1a00a 100644 --- a/src/Illuminate/Queue/Console/ResumeCommand.php +++ b/src/Illuminate/Queue/Console/ResumeCommand.php @@ -5,6 +5,7 @@ use Illuminate\Console\Command; use Illuminate\Contracts\Queue\Factory as QueueManager; use Illuminate\Queue\Console\Concerns\ParsesQueue; +use Illuminate\Queue\Worker; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'queue:resume', aliases: ['queue:continue'])] @@ -40,6 +41,12 @@ class ResumeCommand extends Command */ public function handle(QueueManager $manager) { + if (! Worker::$pausable) { + $this->components->error('Worker::$pausable must be set to true to use this command.'); + + return 1; + } + [$connection, $queue] = $this->parseQueue($this->argument('queue')); $manager->resume($connection, $queue);