-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Rework the signal integration #37827
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
+77
−28
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fabpot
requested changes
Aug 13, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor comments
src/Symfony/Component/Console/Command/SignalableCommandInterface.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Console/Command/SignalableCommandInterface.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Console/Command/SignalableCommandInterface.php
Outdated
Show resolved
Hide resolved
f9514aa
to
b39d3e9
Compare
@fabpot I addressed your comments. Thanks |
fabpot
approved these changes
Aug 13, 2020
2993709
to
93c7e1f
Compare
Oh, don't merge this PR, there are something wrong: Since we listen some signal, the app never stop :) |
Fixed :) |
fabpot
approved these changes
Aug 13, 2020
Thank you @lyrixx. |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I updated the code to have a better design and DX:
SignalRegistry::$handlingSignals
is gone. This was a temporary data store tobind signal to symfony event. This does not belong to the
SignalRegistry
. Ithas been replaced by
Application::$signalsToDispatchEvent
. A method has beenadded to edit this list
Application::setSignalsToDispatchEvent()
The default value for
Application::$signalsToDispatchEvent
isSIGINT, SIGTERM, SIGUSR1, SIGUSR2
. Theses defaults seems good enough for most ofapplication. for recall:
SIGINT
: CTRL+CSIGTERM
:kill PID
, this is what occurs when stopping a process with SystemD, upstart & coSIGUSR1
andSIGUSR2
: Signal for user spaceApplication::setSignalRegistry()
is gone. Now the Application always owns asignal registry. Since it's a CLI, it's legit to always have support for
signals. A method has been added for convenience, and to register signal
handler manually from the command:
The interface
SignalableCommandInterface
has been added. When a commandimplements this interface, the command is automatically called when a
registered signal has been caught
A note about the BC:
existing registered handlers. The BC is kept ✅
behavior. Since the feature is new. the BC is kept ✅
So now, If one want to listen a signal, they have few options depending on the context:
A global action is common to all commands (such as logging, enabling a
profiler (👋 blackfire.io)): Use a listener. With autoconfigure, the following
code is enough:
The command should react to a signal: Implements the interface:
The command should react differently to many event and/or one wants a full control on name of the method called
ping @marie