Skip to content

[FrameworkBundle] Make StopWorkerOnSignalsListener configurable via messenger's config #18113

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

Open
wants to merge 1 commit into
base: 6.3
Choose a base branch
from
Open
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
54 changes: 53 additions & 1 deletion messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,59 @@ message before terminating.

However, you might prefer to use different POSIX signals for graceful shutdown.
You can override default ones by setting the ``framework.messenger.stop_worker_on_signals``
configuration option.
configuration option:

.. configuration-block::

.. code-block:: yaml

# config/packages/messenger.yaml
framework:
messenger:
stop_worker_on_signals:
- "SIGINT"
- "SIGTERM"
- "SIGUSR1"

# ...

.. code-block:: xml

<!-- config/packages/messenger.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:messenger>
<!-- ... -->

<framework:stop-worker-on-signals signal="SIGINT"/>
<framework:stop-worker-on-signals signal="SIGTERM"/>
<framework:stop-worker-on-signals signal="SIGUSR1"/>
</framework:messenger>
</framework:config>
</container>

.. code-block:: php

use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
$messenger = $framework->messenger();

// ...

$messenger
->stopWorkerOnSignals([\SIGINT, \SIGTERM, \SIGUSR1])
// ...
;
};

.. versionadded:: 6.3

Expand Down