backport more error information from 2.6 to 2.3

The commit on master was:

server:run command: provide more error information

The server:run command didn't provide many information when the executed
command exited unexpectedly. Now, the process' exit code is passed through
and an error message is displayed.
This commit is contained in:
Christian Flothmann 2014-07-13 13:34:23 +02:00
parent 80536d012d
commit 87449e04f2
1 changed files with 12 additions and 1 deletions

View File

@ -106,10 +106,21 @@ EOF
$builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router));
$builder->setWorkingDirectory($documentRoot);
$builder->setTimeout(null);
$builder->getProcess()->run(function ($type, $buffer) use ($output) {
$process = $builder->getProcess();
$process->run(function ($type, $buffer) use ($output) {
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
$output->write($buffer);
}
});
if (!$process->isSuccessful()) {
$output->writeln('<error>Built-in server terminated unexpectedly</error>');
if (OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) {
$output->writeln('<error>Run the command again with -v option for more details</error>');
}
}
return $process->getExitCode();
}
}