Ejemplo n.º 1
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $server = new Server($this->getContainer()->getParameter('kernel.root_dir'), $input->getOption('port'));
     $output->writeln(sprintf('<info>Server running on port %s.</info>', $input->getOption('port')));
     $server->setEnv($this->getContainer()->getParameter('kernel.environment'))->setStandalone($input->getOption('standalone'))->setApc($input->getOption('apc'))->setCache($input->getOption('cache'))->build()->run();
     $output->writeln('<info>Server stopped.</info>');
 }
Ejemplo n.º 2
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     if (!extension_loaded('pcntl')) {
         $output->writeln('<error>PCNTL PHP extension is not installed or loaded, please enable it before launching server.</error>');
         return 1;
     }
     $output->writeln(sprintf('<info>Server running on port %s.</info>', $input->getOption('port')));
     $port = $input->getOption('port');
     $pid = pcntl_fork();
     if ($pid > 0) {
         $lock_file = sys_get_temp_dir() . '/react-' . $port . '.pid';
         file_put_contents($lock_file, $pid);
         return 0;
     } elseif ($pid < 0) {
         $output->writeln('<error>Child process could not be started. Server is not running.</error>');
         return 1;
     }
     $server = new Server($this->getContainer()->getParameter('kernel.root_dir'), $port);
     $server->setEnv($this->getContainer()->getParameter('kernel.environment'))->setStandalone($input->getOption('standalone'))->setApc($input->getOption('apc'))->setCache($input->getOption('cache'))->build()->run();
 }