-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathResetCommand.php
36 lines (29 loc) · 1.03 KB
/
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
29
30
31
32
33
34
35
36
<?php
namespace Dtc\QueueBundle\Command;
use Dtc\QueueBundle\Manager\JobManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ResetCommand extends Command
{
/** @var JobManagerInterface */
private $jobManager;
protected function configure(): void
{
$this
->setName('dtc:queue:reset')
->setDescription('Reset jobs with exception or stalled status');
}
public function setJobManager($jobManager)
{
$this->jobManager = $jobManager;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$countException = $this->jobManager->resetExceptionJobs();
$countStalled = $this->jobManager->resetStalledJobs();
$output->writeln("$countException job(s) in status 'exception' reset");
$output->writeln("$countStalled job(s) stalled (in status 'running') reset");
return $this::SUCCESS;
}
}