示例#1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $phorever = new Phorever($this->config, $this->getLogger());
     if ($input->getOption('daemon')) {
         $daemon = new Daemon($this->config['pidfile'], $this->getLogger());
         $output->write("Starting Phorever... ");
         $daemon->start(function () use($phorever, $input) {
             $phorever->run(array('role' => $input->getArgument('role')));
         });
         $output->writeln("<info>OK!</info>");
     } else {
         if ($input->getOption('force-pidfile')) {
             if (file_exists($this->config['pidfile'])) {
                 throw new \Exception("PID File {$this->config['pidfile']} already exists!");
             }
             $this->logger->debug("Writing PID File");
             file_put_contents($this->config['pidfile'], getmypid());
         }
         $phorever->run(array('role' => $input->getArgument('role')));
     }
 }