From dbeab6ff7841f6dc4b099a9e9a5d8be2f0cb27c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20M=C3=B3ricz?= Date: Thu, 29 May 2025 19:26:57 +0200 Subject: [PATCH] feat(api): better entrypoint logging --- apps/api/docker-entrypoint.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/api/docker-entrypoint.sh b/apps/api/docker-entrypoint.sh index d6a72593..aa11432d 100755 --- a/apps/api/docker-entrypoint.sh +++ b/apps/api/docker-entrypoint.sh @@ -3,32 +3,33 @@ if [ "$UID" -eq 0 ]; then set +e # disable failing on errror ulimit -n 65535 - echo "NEW ULIMIT: $(ulimit -n)" + echo "ENTRYPOINT: NEW ULIMIT: $(ulimit -n)" set -e # enable failing on error else - echo ENTRYPOINT DID NOT RUN AS ROOT + echo "ENTRYPOINT: DID NOT RUN AS ROOT" fi if [ "$FLY_PROCESS_GROUP" = "app" ]; then - echo "RUNNING app" + echo "ENTRYPOINT: RUNNING app" exec node --max-old-space-size=6144 dist/src/index.js & elif [ "$FLY_PROCESS_GROUP" = "worker" ]; then - echo "RUNNING worker" + echo "ENTRYPOINT: RUNNING worker" exec node --max-old-space-size=3072 dist/src/services/queue-worker.js & elif [ "$FLY_PROCESS_GROUP" = "index-worker" ]; then - echo "RUNNING index worker" + echo "ENTRYPOINT: RUNNING index worker" exec node --max-old-space-size=3072 dist/src/services/indexing/index-worker.js & else - echo "NO FLY PROCESS GROUP" + echo "ENTRYPOINT: NO FLY PROCESS GROUP" exec node --max-old-space-size=8192 dist/src/index.js & fi FC_PID=$! +echo "ENTRYPOINT: Background process PID: $FC_PID" -trap 'kill -SIGTERM $FC_PID; wait $FC_PID' SIGTERM -trap 'kill -SIGINT $FC_PID; wait $FC_PID' SIGINT -trap 'kill -SIGKILL $FC_PID; wait $FC_PID' SIGKILL +trap 'echo "ENTRYPOINT: SIGTERM received. Forwarding to PID $FC_PID..."; kill -SIGTERM $FC_PID; echo "ENTRYPOINT: Waiting for PID $FC_PID to exit after SIGTERM..."; wait $FC_PID; echo "ENTRYPOINT: PID $FC_PID exited after SIGTERM."' SIGTERM +trap 'echo "ENTRYPOINT: SIGINT received. Forwarding to PID $FC_PID..."; kill -SIGINT $FC_PID; echo "ENTRYPOINT: Waiting for PID $FC_PID to exit after SIGINT..."; wait $FC_PID; echo "ENTRYPOINT: PID $FC_PID exited after SIGINT."' SIGINT +echo "ENTRYPOINT: Main script waiting for PID $FC_PID..." wait $FC_PID -echo "ALL PROCESSES TERMINATED" +echo "ENTRYPOINT: All processes terminated. Script exiting."