|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Gearman Bundle for Symfony2 / Symfony3 |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
* |
|
9
|
|
|
* Feel free to edit as you please, and have fun. |
|
10
|
|
|
* |
|
11
|
|
|
* @author Marc Morera <[email protected]> |
|
12
|
|
|
* @author Mickael Perraud <[email protected]> |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Mkk\GearmanBundle\Command; |
|
16
|
|
|
|
|
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
19
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Gearman Job List Command class |
|
23
|
|
|
*/ |
|
24
|
|
|
class GearmanWorkerListCommand extends ContainerAwareCommand |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Console Command configuration |
|
28
|
|
|
*/ |
|
29
|
16 |
|
protected function configure() |
|
30
|
|
|
{ |
|
31
|
16 |
|
parent::configure(); |
|
32
|
|
|
|
|
33
|
|
|
$this |
|
34
|
16 |
|
->setName('gearman:worker:list') |
|
35
|
16 |
|
->setDescription('List all Gearman Workers and their Jobs'); |
|
36
|
16 |
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Executes the current command. |
|
40
|
|
|
* |
|
41
|
|
|
* @param InputInterface $input An InputInterface instance |
|
42
|
|
|
* @param OutputInterface $output An OutputInterface instance |
|
43
|
|
|
* |
|
44
|
|
|
* @return integer 0 if everything went fine, or an error code |
|
|
|
|
|
|
45
|
|
|
* |
|
46
|
|
|
* @throws \LogicException When this abstract class is not implemented |
|
47
|
|
|
*/ |
|
48
|
2 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
49
|
|
|
{ |
|
50
|
2 |
|
if ($input->getOption('quiet')) { |
|
51
|
|
|
return; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
2 |
|
$workers = $this->getContainer()->get('gearman')->getWorkers(); |
|
55
|
|
|
|
|
56
|
2 |
|
if (is_array($workers)) { |
|
57
|
|
|
|
|
58
|
2 |
|
$it = 1; |
|
|
|
|
|
|
59
|
|
|
|
|
60
|
2 |
|
foreach ($workers as $worker) { |
|
61
|
|
|
|
|
62
|
1 |
|
$output->writeln('<comment>@Worker: </comment><info>' . $worker['className'] . '</info>'); |
|
63
|
1 |
|
$output->writeln('<comment>callablename: </comment><info>' . $worker['callableName'] . '</info>'); |
|
64
|
1 |
|
$output->writeln('<comment>Jobs:</comment>'); |
|
65
|
1 |
|
foreach ($worker['jobs'] as $job) { |
|
66
|
1 |
|
$output->writeln('<comment> - #' . $it++ . '</comment>'); |
|
|
|
|
|
|
67
|
1 |
|
$output->writeln('<comment> name: ' . $job['methodName'] . '</comment>'); |
|
68
|
1 |
|
$output->writeln('<comment> callablename:</comment><info> ' . $job['realCallableNameNoPrefix'] . '</info>'); |
|
|
|
|
|
|
69
|
|
|
|
|
70
|
1 |
|
if (false === is_null($job['jobPrefix'])) { |
|
71
|
|
|
|
|
72
|
1 |
|
$output->writeln('<comment> jobPrefix:</comment><info> ' . $job['jobPrefix'] . '</info>'); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
2 |
|
} |
|
78
|
|
|
} |
|
|
|
|
|
|
79
|
|
|
|
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.