/**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pidFile = $this->config->getEntry($this->config->getEntry('server.pidfile'));
     if (file_exists($pidFile)) {
         $pid = file_get_contents($pidFile);
         if (Posix::isPidActive($pid)) {
             echo 'Slackbot server is running';
         } else {
             echo 'Slackbot server is not running';
         }
     } else {
         echo 'Slackbot server is not running';
     }
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pidFile = $this->config->getEntry($this->config->getEntry('server.rtmpidfile'));
     if (file_exists($pidFile)) {
         $pid = file_get_contents($pidFile);
         if (Posix::isPidActive($pid)) {
             posix_kill($pid, SIGINT);
             echo 'RTM listener stopped';
         } else {
             echo 'RTM listener is not running';
         }
         unlink($pidFile);
     } else {
         echo 'RTM listener is not running';
     }
 }
 /**
  * Checks if another server process with the same config is running
  *
  * @return bool
  */
 protected function checkPidFile()
 {
     /** @var Config $config */
     $config = Registry::get('container')['config'];
     $pidFile = $config->getEntry('server.pidfile');
     if (null === $pidFile) {
         throw new \RuntimeException('server.pidfile value should be set in config');
     }
     if (file_exists($pidFile)) {
         $pid = file_get_contents($pidFile);
         if (Posix::isPidActive($pid)) {
             return false;
         }
         unlink($pidFile);
     }
     file_put_contents($pidFile, getmypid());
     return true;
 }
 /**
  * @param string|null $pidFile
  * @return bool
  */
 private function checkPidFile($pidFile)
 {
     if (file_exists($pidFile)) {
         $pid = file_get_contents($pidFile);
         if (Posix::isPidActive($pid)) {
             return false;
         }
         unlink($pidFile);
     }
     file_put_contents($pidFile, getmypid());
     return true;
 }
 public function processCommand(array $args, $channel)
 {
     Logger::get()->warning('Server restarted by %s', $this->getCallerName());
     Posix::execute(['sudo service supervisord restart']);
 }