/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $output->writeln('<info>PurePHP server started.</info>'); } $server = new Server($input->getOption('port'), $input->getOption('host')); if (OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity()) { $server->setLogger(function ($log) use($output) { $output->writeln($log); }); } $server->run(); }
/** * While idle master, print information about finished tasks. */ public function idle() { if ($this->wait) { $taskToDoStorage = $this->pure->getStorage('tasks_to_do'); foreach ($this->tasksToDo as $serverName => $taskName) { if (!$taskToDoStorage->has($serverName)) { $this->informer->endOnServer($serverName); unset($this->tasksToDo[$serverName]); } } if (count($taskToDoStorage) === 0) { if ($this->isSuccessfullyFinished) { $this->informer->endTask(); } else { $this->informer->taskError($this->hasNonFatalException); } // We waited all workers to finish their tasks. // Wait no more! $this->wait = false; if ($this->isSuccessfullyFinished || $this->hasNonFatalException) { // Reset to default for next tasks. $this->isSuccessfullyFinished = true; } } } }