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
|
|
|
|
2018-02-01 11:49:40 +00:00
|
|
|
use AzuraCast\Radio\Configuration;
|
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()
|
|
|
|
{
|
2017-06-18 02:11:01 +00:00
|
|
|
$this->setName('azuracast:radio:restart')
|
2016-09-18 00:00:46 +00:00
|
|
|
->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
|
|
|
{
|
2018-02-27 06:28:09 +00:00
|
|
|
$output->writeLn('Restarting all radio stations...');
|
2016-09-03 01:41:17 +00:00
|
|
|
|
2018-02-01 11:49:40 +00:00
|
|
|
/** @var \Supervisor\Supervisor $supervisor */
|
2018-01-22 16:28:41 +00:00
|
|
|
$supervisor = $this->di[\Supervisor\Supervisor::class];
|
2016-12-13 05:20:17 +00:00
|
|
|
|
2016-09-27 04:16:34 +00:00
|
|
|
/** @var EntityManager $em */
|
2018-01-22 16:28:41 +00:00
|
|
|
$em = $this->di[EntityManager::class];
|
2018-02-01 11:49:40 +00:00
|
|
|
|
|
|
|
/** @var Configuration $configuration */
|
|
|
|
$configuration = $this->di[Configuration::class];
|
|
|
|
|
|
|
|
/** @var Station[] $stations */
|
2016-09-27 04:16:34 +00:00
|
|
|
$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) {
|
2018-02-27 06:28:09 +00:00
|
|
|
$output->writeLn('Restarting station #' . $station->getId() . ': ' . $station->getName());
|
2018-02-01 11:49:40 +00:00
|
|
|
$configuration->writeConfiguration($station);
|
2016-09-03 01:41:17 +00:00
|
|
|
}
|
2016-12-13 05:20:17 +00:00
|
|
|
|
|
|
|
$supervisor->startAllProcesses();
|
2016-09-03 01:41:17 +00:00
|
|
|
}
|
|
|
|
}
|