4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-12 20:26:43 +00:00
AzuraCast/app/src/AzuraCast/Console/Command/RestartRadio.php

51 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace AzuraCast\Console\Command;
use Doctrine\ORM\EntityManager;
use Entity\Station;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class RestartRadio extends \App\Console\Command\CommandAbstract
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('radio:restart')
->setDescription('Restart all radio stations.');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
\App\Debug::setEchoMode(true);
\App\Debug::log('Restarting all radio stations...');
\App\Debug::divider();
/** @var \Supervisor\Supervisor */
$supervisor = $this->di['supervisor'];
/** @var EntityManager $em */
$em = $this->di['em'];
$stations = $em->getRepository(Station::class)->findAll();
$supervisor->stopAllProcesses();
foreach ($stations as $station) {
/** @var Station $station */
\App\Debug::log('Restarting station #' . $station->id . ': ' . $station->name);
$station->writeConfiguration($this->di);
\App\Debug::divider();
}
$supervisor->startAllProcesses();
}
}