Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $docroot = $this->getContainer()->getParameter('sculpin.output_dir');
     $kernel = $this->getContainer()->get('kernel');
     $httpServer = new HttpServer($output, $docroot, $kernel->getEnvironment(), $kernel->isDebug(), $input->getOption('port'));
     $httpServer->run();
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     foreach ($this->getApplication()->getMissingSculpinBundlesMessages() as $message) {
         $output->writeln($message);
     }
     $docroot = $this->getContainer()->getParameter('sculpin.output_dir');
     if ($input->getOption('clean')) {
         $this->clean($input, $output, $docroot);
     }
     $watch = $input->getOption('watch') ?: false;
     $sculpin = $this->getContainer()->get('sculpin');
     $dataSource = $this->getContainer()->get('sculpin.data_source');
     $sourceSet = new SourceSet();
     $config = $this->getContainer()->get('sculpin.site_configuration');
     if ($url = $input->getOption('url')) {
         $config->set('url', $url);
     }
     $consoleIo = new ConsoleIo($input, $output, $this->getApplication()->getHelperSet());
     if ($input->getOption('server')) {
         $sculpin->run($dataSource, $sourceSet, $consoleIo);
         $kernel = $this->getContainer()->get('kernel');
         $httpServer = new HttpServer($output, $docroot, $kernel->getEnvironment(), $kernel->isDebug(), $input->getOption('port'));
         if ($watch) {
             $httpServer->addPeriodicTimer(1, function () use($sculpin, $dataSource, $sourceSet, $consoleIo) {
                 clearstatcache();
                 $sourceSet->reset();
                 $sculpin->run($dataSource, $sourceSet, $consoleIo);
             });
         }
         $httpServer->run();
     } else {
         do {
             $sculpin->run($dataSource, $sourceSet, $consoleIo);
             if ($watch) {
                 sleep(2);
                 clearstatcache();
                 $sourceSet->reset();
             }
         } while ($watch);
     }
 }