Skip to content

Commit be0784d

Browse files
committed
minor #20646 [FrameworkBundle] Allow to pass signals to StopWorkerOnSignalsListener 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 Closes #20645 Commits ------- cf1d8f1 [FrameworkBundle] Allow to pass signals to `StopWorkerOnSignalsListener` in XML config and as plain strings
2 parents bed495c + cf1d8f1 commit be0784d

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

messenger.rst

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,56 @@ 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:: yaml
856+
857+
# config/packages/messenger.yaml
858+
framework:
859+
messenger:
860+
stop_worker_on_signals:
861+
- SIGTERM
862+
- SIGINT
863+
- SIGUSR1
864+
865+
.. code-block:: xml
866+
867+
<!-- config/packages/messenger.xml -->
868+
<?xml version="1.0" encoding="UTF-8" ?>
869+
<container xmlns="http://symfony.com/schema/dic/services"
870+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
871+
xmlns:framework="http://symfony.com/schema/dic/symfony"
872+
xsi:schemaLocation="http://symfony.com/schema/dic/services
873+
https://symfony.com/schema/dic/services/services-1.0.xsd
874+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
875+
876+
<framework:config>
877+
<framework:messenger>
878+
<!-- ... -->
879+
<framework:stop-worker-on-signal>SIGTERM</framework:stop-worker-on-signal>
880+
<framework:stop-worker-on-signal>SIGINT</framework:stop-worker-on-signal>
881+
<framework:stop-worker-on-signal>SIGUSR1</framework:stop-worker-on-signal>
882+
</framework:messenger>
883+
</framework:config>
884+
</container>
885+
886+
.. code-block:: php
887+
888+
// config/packages/messenger.php
889+
use Symfony\Config\FrameworkConfig;
890+
891+
return static function (FrameworkConfig $framework): void {
892+
$framework->messenger()
893+
->stopWorkerOnSignals(['SIGTERM', 'SIGINT', 'SIGUSR1']);
894+
};
895+
896+
.. versionadded:: 7.3
897+
898+
Support for signals plain name in configuration was introduced in Symfony 7.3.
899+
Prior to this, you had to use the numeric values of the signals as defined
900+
in the ``pcntl`` extension's `predefined constants`_.
852901

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

0 commit comments

Comments
 (0)