2016-09-03 01:41:17 +00:00
|
|
|
<?php
|
2016-12-16 20:49:07 +00:00
|
|
|
namespace AzuraCast\Console\Command;
|
2016-09-03 01:41:17 +00:00
|
|
|
|
2016-09-27 04:16:34 +00:00
|
|
|
use Doctrine\ORM\EntityManager;
|
|
|
|
use Entity\Station;
|
2016-09-18 00:00:46 +00:00
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
2016-12-16 20:49:07 +00:00
|
|
|
class RestartRadio extends \App\Console\Command\CommandAbstract
|
2016-09-03 01:41:17 +00:00
|
|
|
{
|
|
|
|
/**
|
2016-09-18 00:00:46 +00:00
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
protected function configure()
|
|
|
|
{
|
|
|
|
$this->setName('radio:restart')
|
|
|
|
->setDescription('Restart all radio stations.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
2016-09-03 01:41:17 +00:00
|
|
|
*/
|
2016-09-18 00:00:46 +00:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
2016-09-03 01:41:17 +00:00
|
|
|
{
|
|
|
|
\App\Debug::setEchoMode(true);
|
|
|
|
|
|
|
|
\App\Debug::log('Restarting all radio stations...');
|
|
|
|
\App\Debug::divider();
|
|
|
|
|
2016-12-13 05:20:17 +00:00
|
|
|
/** @var \Supervisor\Supervisor */
|
|
|
|
$supervisor = $this->di['supervisor'];
|
|
|
|
|
2016-09-27 04:16:34 +00:00
|
|
|
/** @var EntityManager $em */
|
|
|
|
$em = $this->di['em'];
|
|
|
|
$stations = $em->getRepository(Station::class)->findAll();
|
2016-09-03 01:41:17 +00:00
|
|
|
|
2016-12-13 05:20:17 +00:00
|
|
|
$supervisor->stopAllProcesses();
|
|
|
|
|
2017-01-24 00:35:16 +00:00
|
|
|
foreach ($stations as $station) {
|
2016-09-27 21:54:19 +00:00
|
|
|
/** @var Station $station */
|
|
|
|
|
2017-01-24 00:35:16 +00:00
|
|
|
\App\Debug::log('Restarting station #' . $station->id . ': ' . $station->name);
|
2016-09-03 01:41:17 +00:00
|
|
|
|
2016-12-13 05:20:17 +00:00
|
|
|
$station->writeConfiguration($this->di);
|
2016-09-03 01:41:17 +00:00
|
|
|
|
|
|
|
\App\Debug::divider();
|
|
|
|
}
|
2016-12-13 05:20:17 +00:00
|
|
|
|
|
|
|
$supervisor->startAllProcesses();
|
2016-09-03 01:41:17 +00:00
|
|
|
}
|
|
|
|
}
|