mirror of
https://github.com/r4sas/recastin-panel
synced 2025-03-13 05:41:20 +00:00
69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
![]() |
<?php
|
||
|
|
||
|
namespace App\Command;
|
||
|
|
||
|
use App\Component\NginxConfigGenerator;
|
||
|
use Doctrine\DBAL\Connection;
|
||
|
use Symfony\Component\Console\Command\Command;
|
||
|
use Symfony\Component\Console\Input\InputInterface;
|
||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||
|
|
||
|
/**
|
||
|
* Class CronRunnerCommand
|
||
|
* @author Soner Sayakci <shyim@posteo.de>
|
||
|
*/
|
||
|
class CronRunnerCommand extends Command
|
||
|
{
|
||
|
/**
|
||
|
* @var Connection
|
||
|
*/
|
||
|
private $connection;
|
||
|
/**
|
||
|
* @var NginxConfigGenerator
|
||
|
*/
|
||
|
private $configGenerator;
|
||
|
|
||
|
/**
|
||
|
* CronRunnerCommand constructor.
|
||
|
* @param null|string $name
|
||
|
* @param Connection $connection
|
||
|
* @param NginxConfigGenerator $configGenerator
|
||
|
* @author Soner Sayakci <shyim@posteo.de>
|
||
|
*/
|
||
|
public function __construct(?string $name = null, Connection $connection, NginxConfigGenerator $configGenerator)
|
||
|
{
|
||
|
parent::__construct($name);
|
||
|
$this->connection = $connection;
|
||
|
$this->configGenerator = $configGenerator;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @author Soner Sayakci <shyim@posteo.de>
|
||
|
*/
|
||
|
protected function configure()
|
||
|
{
|
||
|
$this
|
||
|
->setName('recast:cron')
|
||
|
->setDescription('Reloads RTMP Server if needed');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param InputInterface $input
|
||
|
* @param OutputInterface $output
|
||
|
* @return int|null|void
|
||
|
* @author Soner Sayakci <shyim@posteo.de>
|
||
|
* @throws \Doctrine\DBAL\DBALException
|
||
|
*/
|
||
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||
|
{
|
||
|
if ($this->connection->fetchColumn('SELECT 1 FROM queue')) {
|
||
|
$this->configGenerator->generate();
|
||
|
system('systemctl reload nginx-rtmp');
|
||
|
|
||
|
$io = new SymfonyStyle($input, $output);
|
||
|
$io->success('Configs generated, rtmp has been reloaded');
|
||
|
$this->connection->executeQuery('TRUNCATE queue');
|
||
|
}
|
||
|
}
|
||
|
}
|