Skip to content

Commit 14c96ca

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Messenger] Supervisor graceful shutdown
2 parents 18686ea + 682fa2c commit 14c96ca

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

messenger.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,23 @@ Next, tell Supervisor to read your config and start your workers:
668668
669669
See the `Supervisor docs`_ for more details.
670670

671+
Graceful Shutdown
672+
~~~~~~~~~~~~~~~~~
673+
674+
If you install the `PCNTL`_ PHP extension in your project, workers will handle
675+
the ``SIGTERM`` POSIX signal to finish processing their current message before
676+
exiting.
677+
678+
In some cases the ``SIGTERM`` signal is sent by Supervisor itself (e.g. stopping
679+
a Docker container having Supervisor as its entrypoint). In these cases you
680+
need to add a ``stopwaitsecs`` key to the program configuration (with a value
681+
of the desired grace period in seconds) in order to perform a graceful shutdown:
682+
683+
.. code-block:: ini
684+
685+
[program:x]
686+
stopwaitsecs=20
687+
671688
.. _messenger-retries-failures:
672689

673690
Retries & Failures
@@ -2118,6 +2135,7 @@ Learn more
21182135
.. _`Enqueue's transport`: https://github.com/sroze/messenger-enqueue-transport
21192136
.. _`streams`: https://redis.io/topics/streams-intro
21202137
.. _`Supervisor docs`: http://supervisord.org/
2138+
.. _`PCNTL`: https://www.php.net/manual/book.pcntl.php
21212139
.. _`SymfonyCasts' message serializer tutorial`: https://symfonycasts.com/screencast/messenger/transport-serializer
21222140
.. _`Long polling`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-short-and-long-polling.html
21232141
.. _`Visibility Timeout`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html

0 commit comments

Comments
 (0)