4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-13 04:36:41 +00:00
AzuraCast/app/library/App/Console/Command/RestartRadio.php

49 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Console\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class RestartRadio extends 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();
$stations = \Entity\Station::fetchAll();
foreach($stations as $station)
{
\App\Debug::log('Restarting station #'.$station->id.': '.$station->name);
$backend = $station->getBackendAdapter();
$frontend = $station->getFrontendAdapter();
$backend->stop();
$frontend->stop();
$frontend->write();
$backend->write();
$frontend->start();
$backend->start();
\App\Debug::divider();
}
}
}