Skip to content

Commit bc85273

Browse files
[FrameworkBundle] Allow to pass signals to StopWorkerOnSignalsListener in XML config and as plain strings
1 parent 4955cc7 commit bc85273

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

messenger.rst

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,55 @@ message before terminating.
848848

849849
However, you might prefer to use different POSIX signals for graceful shutdown.
850850
You can override default ones by setting the ``framework.messenger.stop_worker_on_signals``
851-
configuration option.
851+
configuration option:
852+
853+
.. configuration-block::
854+
855+
.. code-block:: php
856+
857+
// config/packages/messenger.php
858+
use Symfony\Config\FrameworkConfig;
859+
860+
return static function (FrameworkConfig $framework): void {
861+
$framework->messenger()
862+
->stopWorkerOnSignals(['SIGTERM', 'SIGINT', 'SIGUSR1']);
863+
};
864+
865+
.. code-block:: yaml
866+
867+
# config/packages/messenger.yaml
868+
framework:
869+
messenger:
870+
stop_worker_on_signals:
871+
- SIGTERM
872+
- SIGINT
873+
- SIGUSR1
874+
875+
.. code-block:: xml
876+
877+
<!-- config/packages/messenger.xml -->
878+
<?xml version="1.0" encoding="UTF-8" ?>
879+
<container xmlns="http://symfony.com/schema/dic/services"
880+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
881+
xmlns:framework="http://symfony.com/schema/dic/symfony"
882+
xsi:schemaLocation="http://symfony.com/schema/dic/services
883+
https://symfony.com/schema/dic/services/services-1.0.xsd
884+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
885+
886+
<framework:config>
887+
<framework:messenger ...>
888+
<framework:stop-worker-on-signal>SIGTERM</framework:stop-worker-on-signal>
889+
<framework:stop-worker-on-signal>SIGINT</framework:stop-worker-on-signal>
890+
<framework:stop-worker-on-signal>SIGUSR1</framework:stop-worker-on-signal>
891+
</framework:messenger>
892+
</framework:config>
893+
</container>
894+
895+
.. versionadded:: 7.3
896+
897+
Support for signals plain name in configuration was introduced in Symfony 7.3.
898+
Prior to this, you had to use the numeric values of the signals as defined
899+
in the ``pcntl`` extension's `predefined constants`_.
852900

853901
In some cases the ``SIGTERM`` signal is sent by Supervisor itself (e.g. stopping
854902
a Docker container having Supervisor as its entrypoint). In these cases you
@@ -3587,3 +3635,4 @@ Learn more
35873635
.. _`high connection churn`: https://www.rabbitmq.com/connections.html#high-connection-churn
35883636
.. _`article about CQRS`: https://martinfowler.com/bliki/CQRS.html
35893637
.. _`SSL context options`: https://php.net/context.ssl
3638+
.. _`predefined constants`: https://www.php.net/pcntl.constants

0 commit comments

Comments
 (0)