This repository was archived by the owner on Apr 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathWorkerCommand.php
More file actions
53 lines (46 loc) · 1.35 KB
/
WorkerCommand.php
File metadata and controls
53 lines (46 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Resque\Console;
use Resque\Worker;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class WorkerCommand extends Command
{
/**
* @return void
*/
protected function configure()
{
parent::configure();
$this
->setName('queue:worker')
->setDescription('Runs a Resque worker')
->addOption(
'queue',
'Q',
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
'A queue to listen to and run jobs from'
)
->addOption(
'interval',
'i',
InputOption::VALUE_REQUIRED,
'Interval in seconds to wait for between reserving jobs',
5
);
// Add old command name as alias
$this->setAliases(['worker']);
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$resque = $this->getResque($output);
$queues = $input->getOption('queue');
$worker = new Worker($resque, $queues);
$worker->work($input->getOption('interval'));
}
}