Skip to content

Commit 07f41f7

Browse files
committed
minor symfony#15535 [Messenger] Supervisor graceful shutdown (AymDev)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [Messenger] Supervisor graceful shutdown >[Messenger] Add details on graceful shutdown Added a section to Messenger's documentation on the workers SIGTERM signal handling when the pcntl extension is installed. I'm making this PR because I struggled to perform a graceful shutdown as described in symfony/symfony#41906 and I think this could help other users in the future. This is my first contribution, I'd be happy to rework anything which doesn't meet the documentation standards. Commits ------- 79d5a07 [Messenger] Supervisor graceful shutdown
2 parents 70ffa9b + 79d5a07 commit 07f41f7

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)