File tree 1 file changed +30
-1
lines changed
1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -645,11 +645,40 @@ FATAL (too many start retries) state when trying to restart when something is
645
645
not yet available. You can prevent this by wrapping the Symfony script with a
646
646
shell script and sleep when the script fails:
647
647
648
+ .. code-block :: bash
649
+
650
+ #! /usr/bin/env bash
651
+
652
+ # Supervisor sends TERM to services when stopped.
653
+ # This wrapper has to pass the signal to it's child.
654
+ # Note that we send TERM (graceful) instead of KILL (immediate).
655
+ _term () {
656
+ echo " [GOT TERM, SIGNALING CHILD]"
657
+ kill -TERM " $child " 2> /dev/null
658
+ exit 1
659
+ }
660
+
661
+ trap _term SIGTERM
662
+
663
+ # Execute console.php with whatever arguments were specified to this script
664
+ " $@ " &
665
+ child=$!
666
+ wait " $child "
667
+ rc=$?
668
+
669
+ # Delay to prevent supervisor from restarting too fast on failure
670
+ sleep 30
671
+
672
+ # Return with the exit code of the wrapped process
673
+ exit $rc
674
+
675
+ The supervisor job would then look like this:
676
+
648
677
.. code-block :: ini
649
678
650
679
; /etc/supervisor/conf.d/messenger-worker.conf
651
680
[program:messenger-consume]
652
- command =sh -c " / php /path/to/your/app/bin/console messenger:consume async --time-limit=3600 || (sleep 30 && false) "
681
+ command =/path/to/your/app/bin/console_wrapper php /path/to/your/app/bin/console messenger:consume async --time-limit =3600"
653
682
...
654
683
655
684
.. _messenger-systemd :
You can’t perform that action at this time.
0 commit comments