/
ResetCommand.php
28 lines (24 loc) · 983 Bytes
/
ResetCommand.php
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
<?php
namespace Dtc\QueueBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ResetCommand extends Command
{
protected function configure()
{
$this
->setName('dtc:queue:reset')
->setDescription('Reset jobs with exception or stalled status');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
// @TODO: move this to dependency injection.
$container = $this->getApplication()->getKernel()->getContainer();
$jobManager = $container->get('dtc_queue.manager.job');
$countException = $jobManager->resetExceptionJobs();
$countStalled = $jobManager->resetStalledJobs();
$output->writeln("$countException job(s) in status 'exception' reset");
$output->writeln("$countStalled job(s) stalled (in status 'running') reset");
}
}