Skip to content

Commit 682fa2c

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: [Messenger] Supervisor graceful shutdown
2 parents e3b3fe7 + 0a47f3a commit 682fa2c

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
@@ -672,6 +672,23 @@ Next, tell Supervisor to read your config and start your workers:
672672
673673
See the `Supervisor docs`_ for more details.
674674

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

677694
Retries & Failures
@@ -2211,6 +2228,7 @@ Learn more
22112228
.. _`Enqueue's transport`: https://github.com/sroze/messenger-enqueue-transport
22122229
.. _`streams`: https://redis.io/topics/streams-intro
22132230
.. _`Supervisor docs`: http://supervisord.org/
2231+
.. _`PCNTL`: https://www.php.net/manual/book.pcntl.php
22142232
.. _`SymfonyCasts' message serializer tutorial`: https://symfonycasts.com/screencast/messenger/transport-serializer
22152233
.. _`Long polling`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-short-and-long-polling.html
22162234
.. _`Visibility Timeout`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html

0 commit comments

Comments
 (0)