Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[FrameworkBundle] Allow to pass signals to StopWorkerOnSignalsListener in XML config and as plain strings #49750

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CHANGELOG
* Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown
* Add `RateLimiterFactoryInterface` as an alias of the `limiter` service
* Add `framework.validation.disable_translation` option
* Add support for signal plain name in the `messenger.stop_worker_on_signals` configuration

7.2
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,7 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode, callable $en
->{$enableIfStandalone('symfony/messenger', MessageBusInterface::class)}()
->fixXmlConfig('transport')
->fixXmlConfig('bus', 'buses')
->fixXmlConfig('stop_worker_on_signal')
->validate()
->ifTrue(fn ($v) => isset($v['buses']) && \count($v['buses']) > 1 && null === $v['default_bus'])
->thenInvalid('You must specify the "default_bus" if you define more than one bus.')
Expand Down Expand Up @@ -1704,7 +1705,26 @@ function ($a) {
->arrayNode('stop_worker_on_signals')
->defaultValue([])
->info('A list of signals that should stop the worker; defaults to SIGTERM and SIGINT.')
->integerPrototype()->end()
->beforeNormalization()
->always(function ($signals) {
if (!\is_array($signals)) {
throw new InvalidConfigurationException('The "stop_worker_on_signals" option must be an array in messenger configuration.');
nicolas-grekas marked this conversation as resolved.
Show resolved Hide resolved
}

return array_map(static function ($v) {
if (\is_string($v) && str_starts_with($v, 'SIG') && \array_key_exists($v, get_defined_constants(true)['pcntl'])) {
return \constant($v);
}

if (!\is_int($v)) {
throw new InvalidConfigurationException('The "stop_worker_on_signals" option must be an array of pcntl signals in messenger configuration.');
nicolas-grekas marked this conversation as resolved.
Show resolved Hide resolved
}

return $v;
}, $signals);
})
->end()
->scalarPrototype()->end()
->end()
->scalarNode('default_bus')->defaultNull()->end()
->arrayNode('buses')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@
<xsd:element name="routing" type="messenger_routing" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="transport" type="messenger_transport" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="bus" type="messenger_bus" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="stop-worker-on-signal" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="default-bus" type="xsd:string" />
<xsd:attribute name="enabled" type="xsd:boolean" />
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.