fix image entrypoint sigterm

This commit is contained in:
avigailo
2025-11-06 10:31:13 +02:00
parent ad37257d7c
commit 304fcb16d4

View File

@@ -18,15 +18,18 @@ init=
active_watchdog_pid= active_watchdog_pid=
cleanup() { cleanup() {
# Stop watchdog process if running local signal="$1"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Signal ${signal} was received, exiting gracefully..." >&2
if [ -n "${active_watchdog_pid}" ] && ps -p ${active_watchdog_pid} > /dev/null 2>&1; then if [ -n "${active_watchdog_pid}" ] && ps -p ${active_watchdog_pid} > /dev/null 2>&1; then
kill -TERM ${active_watchdog_pid} 2>/dev/null || true kill -TERM ${active_watchdog_pid} 2>/dev/null || true
wait ${active_watchdog_pid} 2>/dev/null || true wait ${active_watchdog_pid} 2>/dev/null || true
fi fi
echo "Cleanup completed. Exiting now." >&2
exit 0 exit 0
} }
trap cleanup SIGTERM SIGINT trap 'cleanup SIGTERM' SIGTERM
trap 'cleanup SIGINT' SIGINT
if [ ! -f /nano-service-installers/$ORCHESTRATION_INSTALLATION_SCRIPT ]; then if [ ! -f /nano-service-installers/$ORCHESTRATION_INSTALLATION_SCRIPT ]; then
echo "Error: agent installation package doesn't exist." echo "Error: agent installation package doesn't exist."