@@ 11-30 (lines=20) @@ | ||
8 | use Symfony\Component\Console\Output\OutputInterface; |
|
9 | use Tavii\SQSJobQueue\Queue\QueueName; |
|
10 | ||
11 | class WorkerStartCommand extends ContainerAwareCommand |
|
12 | { |
|
13 | protected function configure() |
|
14 | { |
|
15 | $this->setName('sqs_job_queue:worker-start') |
|
16 | ->setDescription('Start a sqs worker') |
|
17 | ->addArgument('queue', InputArgument::REQUIRED, 'Queue name') |
|
18 | ->addOption('sleep', 'S', InputOption::VALUE_OPTIONAL, 'sleep time', 5) |
|
19 | ->addOption('foreground', 'f', InputOption::VALUE_NONE, 'Should the worker run in foreground') |
|
20 | ; |
|
21 | } |
|
22 | ||
23 | protected function execute(InputInterface $input, OutputInterface $output) |
|
24 | { |
|
25 | $queueName = new QueueName($input->getArgument('queue'), $this->getContainer()->getParameter('sqs_job_queue.prefix')); |
|
26 | $worker = $this->getContainer()->get('sqs_job_queue.worker'); |
|
27 | $worker->start($queueName, $input->getOption('sleep')); |
|
28 | } |
|
29 | ||
30 | } |
@@ 11-29 (lines=19) @@ | ||
8 | use Symfony\Component\Console\Output\OutputInterface; |
|
9 | use Tavii\SQSJobQueue\Queue\QueueName; |
|
10 | ||
11 | class WorkerStopCommand extends ContainerAwareCommand |
|
12 | { |
|
13 | protected function configure() |
|
14 | { |
|
15 | $this->setName('sqs_job_queue:worker-stop') |
|
16 | ->setDescription('Stop a sqs worker') |
|
17 | ->addArgument('queue', InputArgument::REQUIRED, 'Queue name') |
|
18 | ->addOption('pid', 'p', InputOption::VALUE_OPTIONAL, 'stop pid name', null) |
|
19 | ->addOption('force', 'f', InputOption::VALUE_NONE, 'force storage delete') |
|
20 | ; |
|
21 | } |
|
22 | ||
23 | protected function execute(InputInterface $input, OutputInterface $output) |
|
24 | { |
|
25 | $queueName = new QueueName($input->getArgument('queue'), $this->getContainer()->getParameter('sqs_job_queue.prefix')); |
|
26 | $worker = $this->getContainer()->get('sqs_job_queue.worker'); |
|
27 | $worker->stop($queueName, $input->getOption('pid'), $input->getOption('force')); |
|
28 | } |
|
29 | } |