Skip to content

Commit 79d5a07

Browse files
AymDevjaviereguiluz
authored andcommitted
[Messenger] Supervisor graceful shutdown
1 parent 70ffa9b commit 79d5a07

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

messenger.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,25 @@ config and start your workers:
653653
654654
See the `Supervisor docs`_ for more details.
655655

656+
Graceful Shutdown
657+
~~~~~~~~~~~~~~~~~
658+
659+
Workers can handle the ``SIGTERM`` POSIX signal to finish handling their
660+
current message before exiting, as long as the `PCNTL`_ extension is installed.
661+
662+
.. tip::
663+
664+
In some cases the ``SIGTERM`` signal is sent by Supervisor itself (e.g.
665+
stopping a Docker container having Supervisor as its entrypoint).
666+
In these cases you need to add a ``stopwaitsecs`` key to the program
667+
configuration (with a value of the desired grace period in seconds)
668+
in order to perform a graceful shutdown.
669+
670+
.. code-block:: ini
671+
672+
[program:x]
673+
stopwaitsecs=20
674+
656675
.. _messenger-retries-failures:
657676

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

0 commit comments

Comments
 (0)