From 0b5dafd1bc9da8b68dcb540bb365a1b0fc96c287 Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Thu, 29 Sep 2016 22:07:36 +0300 Subject: [PATCH] [5.3] Update and fix Queue commands (#15677) * Use the new command signature and include command as argument in work command * update style * update style --- .../Queue/Console/DaemonCommand.php | 54 ++++--------------- src/Illuminate/Queue/Console/WorkCommand.php | 41 ++++---------- 2 files changed, 22 insertions(+), 73 deletions(-) diff --git a/src/Illuminate/Queue/Console/DaemonCommand.php b/src/Illuminate/Queue/Console/DaemonCommand.php index 81e603a666d8..f8c017ebc844 100755 --- a/src/Illuminate/Queue/Console/DaemonCommand.php +++ b/src/Illuminate/Queue/Console/DaemonCommand.php @@ -9,8 +9,6 @@ use Illuminate\Contracts\Queue\Job; use Illuminate\Queue\Events\JobFailed; use Illuminate\Queue\Events\JobProcessed; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputArgument; class DaemonCommand extends Command { @@ -19,7 +17,17 @@ class DaemonCommand extends Command * * @var string */ - protected $name = 'queue:daemon'; + protected $signature = 'queue:work + {connection? : The name of connection} + {--queue= : The queue to listen on} + {--daemon : Run the worker in daemon mode (Deprecated)} + {--once : Only process the next job on the queue} + {--delay=0 : Amount of time to delay failed jobs} + {--force : Force the worker to run even in maintenance mode} + {--memory=128 : The memory limit in megabytes} + {--sleep=3 : Number of seconds to sleep when no job is available} + {--timeout=60 : The number of seconds a child process can run} + {--tries=0 : Number of times to attempt a job before logging it failed}'; /** * The console command description. @@ -181,44 +189,4 @@ protected function downForMaintenance() { return $this->option('force') ? false : $this->laravel->isDownForMaintenance(); } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['connection', InputArgument::OPTIONAL, 'The name of connection', null], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['queue', null, InputOption::VALUE_OPTIONAL, 'The queue to listen on'], - - ['daemon', null, InputOption::VALUE_NONE, 'Run the worker in daemon mode (Deprecated)'], - - ['once', null, InputOption::VALUE_NONE, 'Only process the next job on the queue'], - - ['delay', null, InputOption::VALUE_OPTIONAL, 'Amount of time to delay failed jobs', 0], - - ['force', null, InputOption::VALUE_NONE, 'Force the worker to run even in maintenance mode'], - - ['memory', null, InputOption::VALUE_OPTIONAL, 'The memory limit in megabytes', 128], - - ['sleep', null, InputOption::VALUE_OPTIONAL, 'Number of seconds to sleep when no job is available', 3], - - ['timeout', null, InputOption::VALUE_OPTIONAL, 'The number of seconds a child process can run', 60], - - ['tries', null, InputOption::VALUE_OPTIONAL, 'Number of times to attempt a job before logging it failed', 0], - ]; - } } diff --git a/src/Illuminate/Queue/Console/WorkCommand.php b/src/Illuminate/Queue/Console/WorkCommand.php index a411320510ed..1e3c12dbc076 100644 --- a/src/Illuminate/Queue/Console/WorkCommand.php +++ b/src/Illuminate/Queue/Console/WorkCommand.php @@ -4,7 +4,6 @@ use Illuminate\Console\Command; use Symfony\Component\Process\Process; -use Symfony\Component\Console\Input\InputOption; class WorkCommand extends Command { @@ -13,7 +12,17 @@ class WorkCommand extends Command * * @var string */ - protected $name = 'queue:work'; + protected $signature = 'queue:work + {connection? : The name of connection} + {--queue= : The queue to listen on} + {--daemon : Run the worker in daemon mode (Deprecated)} + {--once : Only process the next job on the queue} + {--delay=0 : Amount of time to delay failed jobs} + {--force : Force the worker to run even in maintenance mode} + {--memory=128 : The memory limit in megabytes} + {--sleep=3 : Number of seconds to sleep when no job is available} + {--timeout=60 : The number of seconds a child process can run} + {--tries=0 : Number of times to attempt a job before logging it failed}'; /** * The console command description. @@ -51,32 +60,4 @@ protected function newProxyProcess() ->setTimeout(null) ->setIdleTimeout($this->option('timeout') + $this->option('sleep')); } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['queue', null, InputOption::VALUE_OPTIONAL, 'The queue to listen on'], - - ['daemon', null, InputOption::VALUE_NONE, 'Run the worker in daemon mode (Deprecated)'], - - ['once', null, InputOption::VALUE_NONE, 'Only process the next job on the queue'], - - ['delay', null, InputOption::VALUE_OPTIONAL, 'Amount of time to delay failed jobs', 0], - - ['force', null, InputOption::VALUE_NONE, 'Force the worker to run even in maintenance mode'], - - ['memory', null, InputOption::VALUE_OPTIONAL, 'The memory limit in megabytes', 128], - - ['sleep', null, InputOption::VALUE_OPTIONAL, 'Number of seconds to sleep when no job is available', 3], - - ['timeout', null, InputOption::VALUE_OPTIONAL, 'The number of seconds a child process can run', 60], - - ['tries', null, InputOption::VALUE_OPTIONAL, 'Number of times to attempt a job before logging it failed', 0], - ]; - } }