mirror of
https://github.com/idanoo/laravel-resque.git
synced 2024-11-24 17:35:19 +00:00
remove possibility to run multiple workers with one command
This commit is contained in:
parent
b99863c0ff
commit
6f941a12cf
@ -20,6 +20,13 @@ class WorkCommand extends IlluminateCommand
|
|||||||
*/
|
*/
|
||||||
protected $name = 'resque:work';
|
protected $name = 'resque:work';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Run a resque worker';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Hlgrrnhrdt\Resque\Resque
|
* @var \Hlgrrnhrdt\Resque\Resque
|
||||||
*/
|
*/
|
||||||
@ -41,27 +48,12 @@ class WorkCommand extends IlluminateCommand
|
|||||||
*/
|
*/
|
||||||
public function fire()
|
public function fire()
|
||||||
{
|
{
|
||||||
$queues = $this->option('queue');
|
$queue = $this->option('queue');
|
||||||
$interval = (int)$this->option('interval');
|
$interval = (int)$this->option('interval');
|
||||||
$count = (int)$this->option('count');
|
|
||||||
|
|
||||||
if ($count > 1) {
|
$queues = explode(',', $queue);
|
||||||
for ($i = 0; $i < $count; $i++) {
|
|
||||||
try {
|
|
||||||
$pid = $this->resque->fork();
|
|
||||||
} catch (\RuntimeException $exception) {
|
|
||||||
$this->error($exception->getMessage());
|
|
||||||
|
|
||||||
return 1;
|
$this->startWorker($queues, $interval);
|
||||||
}
|
|
||||||
|
|
||||||
if (0 === $pid) {
|
|
||||||
$this->startWorker($queues, $interval);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$this->startWorker($queues, $interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -73,8 +65,7 @@ class WorkCommand extends IlluminateCommand
|
|||||||
private function startWorker(array $queues, $interval = 5)
|
private function startWorker(array $queues, $interval = 5)
|
||||||
{
|
{
|
||||||
$worker = new Resque_Worker($queues);
|
$worker = new Resque_Worker($queues);
|
||||||
|
$this->info(\sprintf('Starting worker %s', $worker));
|
||||||
$this->info(sprintf('Starting worker %s', $worker));
|
|
||||||
$worker->work($interval);
|
$worker->work($interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,17 +75,8 @@ class WorkCommand extends IlluminateCommand
|
|||||||
protected function getOptions()
|
protected function getOptions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[
|
['queue', null, InputOption::VALUE_OPTIONAL, 'The queue to work on', 'default'],
|
||||||
'queue',
|
['interval', null, InputOption::VALUE_OPTIONAL, 'Amount of time to delay failed jobs', 5],
|
||||||
null,
|
|
||||||
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
|
|
||||||
'The queue to work on',
|
|
||||||
['default'],
|
|
||||||
],
|
|
||||||
['interval', null, InputOption::VALUE_OPTIONAL, 'The queue to work on', 5],
|
|
||||||
['count', null, InputOption::VALUE_OPTIONAL, 'The queue to work on', 1],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user