public function testControllerWithManyDaemons() { $child = $this->getChildMock(); $daemon = $this->getDaemonMock(); $daemon2 = clone $daemon; $child->expects($this->exactly(2))->method('run'); $controller = new MasterController($this->loop, $child); $controller->attach($daemon); $controller->attach($daemon2); $controller->start(); $this->manyTicks(); }
protected function execute(InputInterface $input, OutputInterface $output) { try { $id = $input->getOption('id'); DaemonUtils::configCheck(); $daemons = DaemonUtils::getDaemonsFromConfig(); file_put_contents(DaemonUtils::getPidFilename(), getmypid() . ',' . $id); $loop = \React\EventLoop\Factory::create(); $master = new MasterController($loop, new ChildController()); foreach ($daemons as $daemon) { if (!$daemon instanceof DaemonizerInterface) { throw new \Exception('Invalid [cli-daemonizer.php] file: file contain not-implementer ' . 'DaemonizerInterface class'); } $master->attach($daemon); } $master->start(); $loop->run(); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); } }