/**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$this->checkPidFile()) {
         $output->write('Error: server is already running, exiting');
         return 1;
     }
     /** @var CoreBuilder $builder */
     $builder = new CoreBuilder($this->config, $this->argParser);
     if (!$this->checkSlackConnection()) {
         $output->writeln('Cannot connect to Slack, exiting.');
         $output->writeln(sprintf('Slack reports: <error>%s</error>', Ar::get($this->testResponse, 'error')));
         return 1;
     }
     /** @var \CapMousse\ReactRestify\Server $server */
     $server = $builder->buildServer();
     $this->runServer($server);
 }
Example #2
0
 /**
  * Configures console application
  */
 public function bootstrap()
 {
     $coreBuilder = new CoreBuilder();
     $this->container = $coreBuilder->buildContainer($this->argParser, $this->config);
     $coreBuilder->buildLogger($this->container);
     Registry::set('container', $this->container);
     $this->app = new ConsoleApp('CMS Slack Bot', '@package_version@');
     $this->app->add(new commands\ServerStartCommand($this->container['config'], $this->container['argv_parser']));
     $this->app->add(new commands\ServerStopCommand($this->container['config']));
     $this->app->add(new commands\ServerStatusCommand($this->container['config']));
     $this->app->add(new commands\PlaybookRunCommand($this->container['curl_request'], $this->container['variables_placer'], $this->container['file_loader']));
     $this->app->add(new commands\RtmStartCommand($this->config, $this->container['curl_request']));
     $this->app->add(new commands\RtmStopCommand($this->container['config']));
     $this->app->add(new commands\CronWorkerCommand($this->container['curl_request'], $this->container['cron_expression'], $this->container['file_loader']));
     $this->app->add(new commands\ApiStubStartCommand());
     $this->app->add(new commands\RtmStubStartCommand());
 }