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

Skip to content

Commit f45c688

Browse files
[FrameworkBundle] Allow to pass signals to StopWorkerOnSignalsListener in XML config and as plain strings
1 parent 38b5992 commit f45c688

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

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

+16-1
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,22 @@ function ($a) {
15311531
->arrayNode('stop_worker_on_signals')
15321532
->defaultValue([])
15331533
->info('A list of signals that should stop the worker; defaults to SIGTERM and SIGINT.')
1534-
->integerPrototype()->end()
1534+
->beforeNormalization()
1535+
->always()
1536+
->then(function ($v) {
1537+
return array_map(static function ($element): int {
1538+
$element = \is_array($element) ? $element['signal'] : $element;
1539+
if (\is_string($element)) {
1540+
$signal = \constant('\\'.$element);
1541+
1542+
return null !== $signal ? $signal : (int) $element;
1543+
}
1544+
1545+
return $element;
1546+
}, $v);
1547+
})
1548+
->end()
1549+
->variablePrototype()->end()
15351550
->end()
15361551
->scalarNode('default_bus')->defaultNull()->end()
15371552
->arrayNode('buses')

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

+5
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@
543543
<xsd:element name="routing" type="messenger_routing" minOccurs="0" maxOccurs="unbounded" />
544544
<xsd:element name="transport" type="messenger_transport" minOccurs="0" maxOccurs="unbounded" />
545545
<xsd:element name="bus" type="messenger_bus" minOccurs="0" maxOccurs="unbounded" />
546+
<xsd:element name="stop-worker-on-signals" type="messenger_stop_worker_on_signals" minOccurs="0" maxOccurs="unbounded" />
546547
</xsd:sequence>
547548
<xsd:attribute name="default-bus" type="xsd:string" />
548549
<xsd:attribute name="enabled" type="xsd:boolean" />
@@ -611,6 +612,10 @@
611612
<xsd:attribute name="id" type="xsd:string" use="required"/>
612613
</xsd:complexType>
613614

615+
<xsd:complexType name="messenger_stop_worker_on_signals">
616+
<xsd:attribute name="signal" type="xsd:string" use="required" />
617+
</xsd:complexType>
618+
614619
<xsd:complexType name="http_client">
615620
<xsd:sequence>
616621
<xsd:element name="default-options" type="http_client_default_options" minOccurs="0" />

0 commit comments

Comments
 (0)
0