Example #1
0
 /**
  * Check if server is running
  *
  * @return bool
  */
 public static function isRunning()
 {
     try {
         $process = new Process(self::getServerPID());
         return $process->isAlive();
     } catch (\Exception $e) {
         return false;
     }
 }
Example #2
0
 /**
  * This method will be called if this command is triggered
  *
  * @param ArgumentsContainer $arguments
  *
  * @return mixed
  */
 public function execute(ArgumentsContainer $arguments)
 {
     if (!ServerHelper::isRunning()) {
         $this->outputDriver->send('[error]Server is not running[/error]' . PHP_EOL, [], true);
         exit(1);
     }
     $process = new Process(ServerHelper::getServerPID());
     if ($process->sendSignal(new Signal(Signal::KILL))) {
         $this->outputDriver->send('[success]Server will stop shortly[/success]' . PHP_EOL);
         exit(0);
     } else {
         $this->outputDriver->send('[error]The server is not responding[/error]' . PHP_EOL, [], true);
         exit(1);
     }
 }
Example #3
0
 /**
  * This method will be called if this command is triggered
  *
  * @param ArgumentsContainer $arguments
  *
  * @return mixed
  */
 public function execute(ArgumentsContainer $arguments)
 {
     if (!ServerHelper::isRunning()) {
         $this->outputDriver->send('[error]Server is not running[/error]' . PHP_EOL, [], true);
         exit(1);
     }
     $process = new Process(ServerHelper::getServerPID());
     if ($process->sendSignal(new Signal(Signal::KILL))) {
         sleep(1);
         Exec::viaPipe('bin/thinframe server start --daemon', KARMA_ROOT);
         $this->outputDriver->send('[info]The server will start shortly[/info]' . PHP_EOL);
         exit(0);
     } else {
         $this->outputDriver->send('[error]The server is not responding[/error]' . PHP_EOL, [], true);
         exit(1);
     }
 }