From 1ce3f0d198665dd3ccdb4f29414cc3b79ea95dd4 Mon Sep 17 00:00:00 2001 From: "k.eaven" Date: Tue, 12 Aug 2025 23:48:42 -0700 Subject: [PATCH] Modify container signal handling --- entrypoint.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5d377fc..33f94c4 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,10 +4,13 @@ python generate_config.py && python pterodisbot.py & # Capture the application's process ID -pid=$! +PID=$! -# Trap the SIGTERM signal and pass it through to the process upon container receiving stop command -trap "kill -TERM $pid" SIGTERM +# Trap SIGTERM (from Docker) and convert it to SIGINT (for Python) +trap "echo 'Received SIGTERM, converting to SIGINT'; kill -SIGINT $PID" SIGTERM -# Wait for process to complete -wait $pid \ No newline at end of file +# Also trap SIGINT (for manual Ctrl+C) and forward it +trap "kill -SIGINT $PID" SIGINT + +# Wait for the process to exit +wait $PID \ No newline at end of file