*/ class CronRunnerCommand extends Command implements ContainerAwareInterface { use ContainerAwareTrait; /** * @var Connection */ private $connection; /** * @var NginxConfigGenerator */ private $configGenerator; /** * CronRunnerCommand constructor. * @param null|string $name * @param Connection $connection * @param NginxConfigGenerator $configGenerator * @author Soner Sayakci */ public function __construct(?string $name = null, Connection $connection, NginxConfigGenerator $configGenerator) { parent::__construct($name); $this->connection = $connection; $this->configGenerator = $configGenerator; } /** * @author Soner Sayakci */ 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 * @throws \Doctrine\DBAL\DBALException */ protected function execute(InputInterface $input, OutputInterface $output) { if ($this->connection->fetchColumn('SELECT 1 FROM queue')) { $this->configGenerator->generate(); system($this->container->getParameter('nginxReloadCommand')); $io = new SymfonyStyle($input, $output); $io->success('Configs generated, rtmp has been reloaded'); $this->connection->executeQuery('TRUNCATE queue'); } } }