From 16d7fbcdf903e4065755fe31461fa9309fd94a7e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 19:57:19 +0000 Subject: [PATCH] Fix service supervision and local variable scoping in ha_entrypoint.sh Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- .templates/ha_entrypoint.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 11a50fb67..cbb60af9f 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -199,8 +199,15 @@ if $PID1; then echo "Starting: $runfile" sed -i "1s|^.*|#!$shebang|" "$runfile" chmod +x "$runfile" - (exec "$runfile") & - true + ( + restart_count=0 + while true; do + "$runfile" || true + restart_count=$((restart_count + 1)) + echo -e "\e[38;5;214m$(date) WARNING: $runfile exited, restarting (#${restart_count}) in 5s...\e[0m" + sleep 5 + done + ) & done shopt -u nullglob fi @@ -214,6 +221,7 @@ if $PID1; then echo -e "\033[0;32mEverything started!\033[0m" terminate() { + local local_pid echo "Termination signal received, forwarding to subprocesses..." if command -v pgrep >/dev/null 2>&1; then while read -r pid; do