-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathExampleStartCommand.php
38 lines (29 loc) · 1.07 KB
/
ExampleStartCommand.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
<?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 ExampleStartCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName('example:start')
->setDescription('Starts the example daemon')
->setHelp(<<<EOT
The <info>{$this->getName()}</info> Run the example daemon in the background.
EOT
);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$daemon = new Daemon($this->getContainer()->getParameter('example.daemon.options'));
$daemon->start();
while ($daemon->isRunning()) {
$this->getContainer()->get('example.control')->run();
}
$daemon->stop();
}
}