Skip to content

Commit ce45e4d

Browse files
committed
[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.
1 parent 70ffa9b commit ce45e4d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

messenger.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,20 @@ 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+
656670
.. _messenger-retries-failures:
657671

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

0 commit comments

Comments
 (0)