Completed
Push — master ( 96809c...29a8a1 )
by Danny
02:46
created

StartCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
namespace MyOnlineStore\Bundle\RabbitMqManagerBundle\Command;
4
5
use MyOnlineStore\Bundle\RabbitMqManagerBundle\Exception\Supervisor\SupervisorAlreadyRunningException;
6
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class StartCommand extends ContainerAwareCommand
12
{
13
    /**
14
     * @inheritdoc
15
     */
16 2
    protected function configure()
17
    {
18 2
        $this
19 2
            ->setName('rabbitmq-manager:start')
20 2
            ->setDescription('start supervisord')
21 2
            ->addOption('generate', null, InputOption::VALUE_NONE, 'Generate configuration files before starting')
22
        ;
23 2
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28 2
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30 2
        if ($input->getOption('generate')) {
31 1
            $this->getContainer()->get('myonlinestore_rabbitmq_manager.config_generator')->generate();
32 1
        }
33
34
        try {
35 2
            $this->getContainer()->get('myonlinestore_rabbitmq_manager.supervisor')->start();
36 2
            $output->writeln('Supervisord is started');
37 2
        } catch (SupervisorAlreadyRunningException $exception) {
38
            $output->writeln(sprintf('<error>%s</error>', $exception->getMessage()));
39
        }
40 2
    }
41
}
42