コード例 #1
0
ファイル: DaemoniseCommand.php プロジェクト: ntoniazzi/PHPCI
 /**
  * Loops through running.
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $cmd = "echo %s > '%s/daemon/daemon.pid'";
     $command = sprintf($cmd, getmypid(), PHPCI_DIR);
     exec($command);
     $this->output = $output;
     $this->run = true;
     $this->sleep = 0;
     $runner = new RunCommand($this->logger);
     $runner->setMaxBuilds(1);
     $runner->setDaemon(true);
     $emptyInput = new ArgvInput(array());
     while ($this->run) {
         $buildCount = 0;
         try {
             $buildCount = $runner->run($emptyInput, $output);
         } catch (\Exception $e) {
             $output->writeln('<error>Exception: ' . $e->getMessage() . '</error>');
             $output->writeln('<error>Line: ' . $e->getLine() . ' - File: ' . $e->getFile() . '</error>');
         }
         if (0 == $buildCount && $this->sleep < 15) {
             $this->sleep++;
         } elseif (1 < $this->sleep) {
             $this->sleep--;
         }
         echo '.' . (0 === $buildCount ? '' : 'build');
         sleep($this->sleep);
     }
 }
コード例 #2
0
 /**
  * Loops through running.
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $runner = new RunCommand($this->logger);
     $runner->setMaxBuilds(1);
     $runner->setDaemon(false);
     /** @var \PHPCI\Store\BuildStore $store */
     $store = Factory::getStore('Build');
     $service = new BuildService($store);
     $lastBuild = array_shift($store->getLatestBuilds(null, 1));
     $service->createDuplicateBuild($lastBuild);
     $runner->run(new ArgvInput(array()), $output);
 }