Skip to content

Commit

Permalink
[5.3] Update and fix Queue commands (#15677)
Browse files Browse the repository at this point in the history
* Use the new command signature and include command as argument in work command

*    update style

*    update style
  • Loading branch information
themsaid authored and taylorotwell committed Sep 29, 2016
1 parent 3fd8cd3 commit 0b5dafd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 73 deletions.
54 changes: 11 additions & 43 deletions src/Illuminate/Queue/Console/DaemonCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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.
Expand Down Expand Up @@ -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],
];
}
}
41 changes: 11 additions & 30 deletions src/Illuminate/Queue/Console/WorkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
use Symfony\Component\Console\Input\InputOption;

class WorkCommand extends Command
{
Expand All @@ -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.
Expand Down Expand Up @@ -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],
];
}
}

0 comments on commit 0b5dafd

Please sign in to comment.