From bb3d724ae7a2a9aa651eb35c76b379eaf5d5e4f7 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:25:41 +0100 Subject: [PATCH] Change order of trap --- .templates/ha_entrypoint.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 2c9644a5d..54cf25115 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -3,12 +3,11 @@ # Only trap SIGTERM if the script's PID is 1 if [ "$$" -eq 1 ]; then - echo "PID is 1, trapping SIGTERM..." set -m terminate() { echo "Termination signal received, forwarding to subprocesses..." - # Check for available commands to terminate subprocesses + # Gracefully terminate subprocesses if command -v pkill &>/dev/null; then pkill -P $$ elif command -v kill &>/dev/null; then @@ -20,7 +19,6 @@ if [ "$$" -eq 1 ]; then echo "All subprocesses terminated. Exiting." exit 0 } - trap terminate SIGTERM SIGINT fi echo "Starting..." @@ -77,7 +75,8 @@ done if [ "$$" -eq 1 ]; then echo " " echo -e "\033[0;32mEverything started!\033[0m" - sleep infinity + trap terminate SIGTERM SIGINT + exec sleep infinity else echo " " echo -e "\033[0;32mStarting the upstream container\033[0m"