Skip to content

[Messenger] Supervisor graceful shutdown #15535

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

Merged
merged 1 commit into from
Jul 20, 2021
Merged
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
20 changes: 20 additions & 0 deletions messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,25 @@ config and start your workers:

See the `Supervisor docs`_ for more details.

Graceful Shutdown
~~~~~~~~~~~~~~~~~

Workers can handle the ``SIGTERM`` POSIX signal to finish handling their
current message before exiting, as long as the `PCNTL`_ extension is installed.

.. tip::

In some cases the ``SIGTERM`` signal is sent by Supervisor itself (e.g.
stopping a Docker container having Supervisor as its entrypoint).
In these cases you need to add a ``stopwaitsecs`` key to the program
configuration (with a value of the desired grace period in seconds)
in order to perform a graceful shutdown.

.. code-block:: ini

[program:x]
stopwaitsecs=20

.. _messenger-retries-failures:

Retries & Failures
Expand Down Expand Up @@ -1747,4 +1766,5 @@ Learn more
.. _`Enqueue's transport`: https://github.com/sroze/messenger-enqueue-transport
.. _`streams`: https://redis.io/topics/streams-intro
.. _`Supervisor docs`: http://supervisord.org/
.. _`PCNTL`: https://www.php.net/manual/book.pcntl.php
.. _`SymfonyCasts' message serializer tutorial`: https://symfonycasts.com/screencast/messenger/transport-serializer