Skip to content

server:run command: provide more error information #11385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2014

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jul 13, 2014

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.

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

This is, for example, useful, if you provide an invalid ip address/hostname on which the server couldn't listen.

$this
->getHelper('process')
->run($output, $process, null, null, OutputInterface::VERBOSITY_VERBOSE);

if ($process->getExitCode() === 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have used !$process->isSuccessful()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the error output would also be shown if the process was terminated by something like kill (the exit code then is 143). Do we consider that to be an unexpected termination? If so, I'll agree with you and will change the code accordingly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would indeed exclude cases where we explicitly interrupt the server (like CTRL+C), but 1 is not the only case for which we need to display this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code. But, 143 is the exit code when the process is kill by another process. Handling Ctrl+C would require some more work (honestly, I'm not sure if that could be handled at all).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To handle Ctrl+C you would have to use POSIX signals (listen to SIGINT) but it will only work on UNIX systems.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think catching Ctrl+C in this context is not really necessary since the server is stopped in this way. Of course, you could handle the signal and ask the user to confirm the termination. But that's not really convenient in most situations I guess.

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.
@fabpot
Copy link
Member

fabpot commented Jul 23, 2014

👍

@fabpot
Copy link
Member

fabpot commented Jul 25, 2014

Thank you @xabbuh.

@fabpot fabpot merged commit 5ba40bf into symfony:master Jul 25, 2014
fabpot added a commit that referenced this pull request Jul 25, 2014
…bbuh)

This PR was merged into the 2.6-dev branch.

Discussion
----------

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.

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This is, for example, useful, if you provide an invalid ip address/hostname on which the server couldn't listen.

Commits
-------

5ba40bf server:run command: provide more error information
@xabbuh xabbuh deleted the server-run-error-handling branch July 25, 2014 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants