public function testRestartWhenStarted()
 {
     $pid_file = $this->server->getConfig()->getPidFile();
     $this->server->start();
     $this->assertFileExists($pid_file);
     $this->assertTrue($this->server->isStarted());
     $this->server->restart();
     $this->assertFileExists($pid_file);
     $this->assertTrue($this->server->isStarted());
     $this->server->stop();
     $this->assertFileNotExists($pid_file);
     $this->assertFalse($this->server->isStarted());
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $logger = $this->getConsoleLogger($output);
     $file = $input->getArgument('config-file');
     // Test if config file exists
     if (!file_exists($file) || !is_readable($file)) {
         $msg = "Configuration file '{$file}' does not exists or is not readable'";
         throw new \InvalidArgumentException($msg);
     }
     $params = (include $file);
     $port = $params['port'];
     $config = new StandaloneServer\Config($params);
     $logger->notice("PJB server using port '{$port}' and config in '{$file}'");
     $this->logServerConfig($logger, $config);
     $this->server = new StandaloneServer($config, $logger);
     $this->server->restart();
     $logger->debug("Server output: \n" . $this->server->getOutput());
     $output->writeln("Server successfully restarted on port {$port}");
     return 0;
 }