-
Notifications
You must be signed in to change notification settings - Fork 10
/
ExampleRestartCommand.php
39 lines (29 loc) · 1.09 KB
/
ExampleRestartCommand.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
37
38
39
<?php
namespace CodeMeme\Bundle\CodeMemeDaemonBundle\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use CodeMeme\Bundle\CodeMemeDaemonBundle\Daemon;
class ExampleRestartCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName('example:restart')
->setDescription('restarts the example daemon')
->setHelp(<<<EOT
The <info>{$this->getName()}</info> Restarts the example daemon running in the background.
EOT
);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$daemon = new Daemon($this->getContainer()->getParameter('example.daemon.options'));
$daemon->reStart();
while ($daemon->isRunning()) {
$this->getContainer()->get('example.control')->run();
}
$daemon->stop();
}
}