From 4e540222bd0f517f908157d60baa22ef97d79464 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:22:22 +0100 Subject: [PATCH] Update ha_entrypoint.sh --- .templates/ha_entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index ae15d185e..8161968ee 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -53,6 +53,7 @@ done # Starting container # ###################### +# If PID 1, keep alive and manage sigterm if [ "$$" -eq 1 ]; then echo " " echo -e "\033[0;32mEverything started!\033[0m" @@ -60,13 +61,12 @@ if [ "$$" -eq 1 ]; then echo "Termination signal received, forwarding to subprocesses..." if command -v pgrep &>/dev/null; then - # Use pgrep if available to find child processes for pid in $(pgrep -P $$); do echo "Terminating child PID $pid" kill -TERM "$pid" 2>/dev/null || echo "Failed to terminate PID $pid" done else - # Fallback to iterating through /proc + # Fallback to iterating through /proc if pgrep is not available for pid in /proc/[0-9]*/; do pid=${pid#/proc/} pid=${pid%/}