8000 [FrameworkBundle] Allow to pass signals to `StopWorkerOnSignalsListen… · symfony/symfony@6b42622 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b42622

Browse files
[FrameworkBundle] Allow to pass signals to StopWorkerOnSignalsListener in XML config and as plain strings
1 parent 4813d66 commit 6b42622

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,7 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode, callable $en
14921492
->{$enableIfStandalone('symfony/messenger', MessageBusInterface::class)}()
14931493
->fixXmlConfig('transport')
14941494
->fixXmlConfig('bus', 'buses')
1495+
->fixXmlConfig('stop_worker_on_signal')
14951496
->validate()
14961497
->ifTrue(function ($v) { return isset($v['buses']) && \count($v['buses']) > 1 && null === $v['default_bus']; })
14971498
->thenInvalid('You must specify the "default_bus" if you define more than one bus.')
@@ -1632,7 +1633,25 @@ function ($a) {
16321633
->arrayNode('stop_worker_on_signals')
16331634
->defaultValue([])
16341635
->info('A list of signals that should stop the worker; defaults to SIGTERM and SIGINT.')
1635-
->integerPrototype()->end()
1636+
->beforeNormalization()
1637+
->always()
1638+
->then(function ($v) {
1639+
return array_map(static function ($element): int|string {
1640+
$element = \is_array($element) ? $element['signal'] : $element;
1641+
1642+
if (\is_string($element)) {
1643+
if (str_starts_with($element, 'SIG') && \array_key_exists($element, get_defined_constants(true)['pcntl'])) {
1644+
$element = \constant($element);
1645+
}
1646+
1647+
return $element;
1648+
}
1649+
1650+
return $element;
1651+
}, $v);
1652+
})
1653+
->end()
1654+
->scalarPrototype()->end()
16361655
->end()
16371656
->scalarNode('default_bus')->defaultNull()->end()
16381657
->arrayNode('buses')

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@
581581
<xsd:element name="routing" type="messenger_routing" minOccurs="0" maxOccurs="unbounded" />
582582
<xsd:element name="transport" type="messenger_transport" minOccurs="0" maxOccurs="unbounded" />
583583
<xsd:element name="bus" type="messenger_bus" minOccurs="0" maxOccurs="unbounded" />
584+
<xsd:element name="stop-worker-on-signal" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
584585
</xsd:sequence>
585586
<xsd:attribute name="default-bus" type="xsd:string" />
586587
<xsd:attribute name="enabled" type="xsd:boolean" />

0 commit comments

Comments
 (0)
0