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