/** * Run daemon. * * @return void */ public function run() { //no fail-safe: this daemon is intended to be run as plain script, otherwise it might fail as well and it can not be controlled. $this->logger->info('Controller for daemons started'); foreach ($this->daemons as $daemon) { if (!$daemon->isRunning()) { $this->logger->warning('Daemon "' . $daemon->getIdentifier() . '" is not running, attempting to invoke'); if ($invocation = $daemon->getInvocation()) { $this->logger->info('Starting daemon "' . $daemon->getIdentifier() . '" by command "' . $invocation . '"'); $this->env->runCliCommandDaemonize($daemon->getInvocation(), $daemon->getIdentifier(), $daemon->getBehavior()); } else { $this->logger->critical('Failed to start daemon "' . $daemon->getIdentifier() . '" as it is configured wrong: no invoking command found'); } } } $this->logger->info('Controller for daemons finished normally'); }
/** * Set signal handlers. * * @return void. */ protected function setSignalHandler() { $this->env->setSignalHandlers(); }