From 6a17690742d625f3a8f74144c2d0b55097609404 Mon Sep 17 00:00:00 2001 From: "k.eaven" Date: Tue, 12 Aug 2025 04:14:52 -0700 Subject: [PATCH] Fix container signal handling --- dockerfile | 2 +- entrypoint.sh | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dockerfile b/dockerfile index cde5bd4..52e0780 100644 --- a/dockerfile +++ b/dockerfile @@ -40,4 +40,4 @@ ENV PYTHONUNBUFFERED=1 ENV CONFIG_PATH=/app/config.ini # Run the bot using the entrypoint script -ENTRYPOINT ["/app/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index bf8aca0..e3d94ca 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,13 @@ #!/bin/sh # Run the application in the background -python generate_config.py && python pterodisbot.py \ No newline at end of file +python generate_config.py && python pterodisbot.py & + +# Capture the application's process ID +pid=$! + +# Trap the SIGTERM signal and pass it through to the process upon stopping the container +trap "kill -TERM $pid" SIGTERM + +# Wait for process to complete +wait $pid \ No newline at end of file