-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Make StopWorkerOnSignalsListener configurable via messenger's config #49702
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
[FrameworkBundle] Make StopWorkerOnSignalsListener configurable via messenger's config #49702
Conversation
624b734
to
3c29da5
Compare
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.
Thanks for your contribution!
It makes sens to me👍🏼
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
3c29da5
to
1808920
Compare
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.
👍🏼 for the code. However, I'm not sure about the wording
@@ -1526,6 +1526,11 @@ function ($a) { | |||
->thenInvalid('The "framework.messenger.reset_on_message" configuration option can be set to "true" only. To prevent services resetting after each message you can set the "--no-reset" option in "messenger:consume" command.') | |||
->end() | |||
->end() | |||
->arrayNode('stop_worker_on_signals') | |||
->defaultValue([]) | |||
->info('A list of signals to stop worker. If not set - use defaults defined in listener.') |
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.
we should be explicit here instead of referencing the listener
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.
@nicolas-grekas updated with clarification of default signals
1808920
to
2584c93
Compare
2584c93
to
9ca9666
Compare
…essenger's config
9ca9666
to
245d75d
Compare
Thank you @rmikalkenas. |
…OnSignalsListener` in XML config and as plain strings (alexandre-daubois) This PR was merged into the 7.3 branch. Discussion ---------- [FrameworkBundle] Allow to pass signals to `StopWorkerOnSignalsListener` in XML config and as plain strings | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | _NA_ | License | MIT | Doc PR | Todo Follow-up of #49702 to improve DX. This PR allows to provide signals this way: ```yaml framework: messenger: transports: async: '%env(MESSENGER_TRANSPORT_DSN)%' stop_worker_on_signals: - SIGINT - SIGUSR1 ``` XML: ```xml <?xml version="1.0" encoding="UTF-8" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <framework:messenger ...> <framework:stop-worker-on-signal>SIGINT</framework:stop-worker-on-signal> <framework:stop-worker-on-signal>SIGTERM</framework:stop-worker-on-signal> <framework:stop-worker-on-signal>SIGUSR1</framework:stop-worker-on-signal> <framework:stop-worker-on-signal>123</framework:stop-worker-on-signal> </framework:messenger> </framework:config> </container> ``` Commits ------- cd91c11 [FrameworkBundle] Add support for signal plain name in the `messenger.stop_worker_on_signals` configuration
At the moment
Symfony\Component\Messenger\EventListener\StopWorkerOnSignalsListener
has hardcoded supported signals: SIGTERM, SIGINT. It's possible to pass custom ones, but it requires a compiler pass class which would override arguments. Adding a possibility to define it via messenger's config would make such configuration more easy.cc @lyrixx