From c1ef92e8320d23a129ffb523968ae43def31a47a Mon Sep 17 00:00:00 2001 From: "k.eaven" Date: Tue, 12 Aug 2025 02:58:05 -0700 Subject: [PATCH] Modify container signal handling --- dockerfile | 13 +++++-------- entrypoint.sh | 13 +++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 entrypoint.sh diff --git a/dockerfile b/dockerfile index 43db197..e028cf3 100644 --- a/dockerfile +++ b/dockerfile @@ -4,12 +4,6 @@ FROM python:3.11-slim # Set working directory WORKDIR /app -# Docker process manager -ENV TINI_VERSION v0.19.0 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini -RUN chmod +x /tini -ENTRYPOINT ["/tini", "--"] - # Install dependencies RUN apt-get update && apt-get install -y \ gcc \ @@ -38,6 +32,9 @@ RUN mkdir -p logs && \ chown -R bot:bot embed && \ chmod -R 777 embed +# Make the entrypoint script executable +RUN chmod +x /app/entrypoint.sh + # Switch to non root user USER bot @@ -45,5 +42,5 @@ USER bot ENV PYTHONUNBUFFERED=1 ENV CONFIG_PATH=/app/config.ini -# Command to run the bot (using exec form and signal handling) -CMD ["sh", "-c", "python generate_config.py && exec python pterodisbot.py"] \ No newline at end of file +# Run the bot using the entrypoint script +ENTRYPOINT ["/app/entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..133d6ea --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Run the application in the background +python generate_config.py && python pterodisbot.py & + +# Capture the process ID +PID=$! + +# Wait for SIGTERM signal +trap "kill -INT $PID" SIGTERM + +# Wait for the process to complete +wait $PID \ No newline at end of file