feat(api): better entrypoint logging

This commit is contained in:
Gergő Móricz 2025-05-29 19:26:57 +02:00
parent 3d5aa7b474
commit dbeab6ff78

View File

@ -3,32 +3,33 @@
if [ "$UID" -eq 0 ]; then if [ "$UID" -eq 0 ]; then
set +e # disable failing on errror set +e # disable failing on errror
ulimit -n 65535 ulimit -n 65535
echo "NEW ULIMIT: $(ulimit -n)" echo "ENTRYPOINT: NEW ULIMIT: $(ulimit -n)"
set -e # enable failing on error set -e # enable failing on error
else else
echo ENTRYPOINT DID NOT RUN AS ROOT echo "ENTRYPOINT: DID NOT RUN AS ROOT"
fi fi
if [ "$FLY_PROCESS_GROUP" = "app" ]; then if [ "$FLY_PROCESS_GROUP" = "app" ]; then
echo "RUNNING app" echo "ENTRYPOINT: RUNNING app"
exec node --max-old-space-size=6144 dist/src/index.js & exec node --max-old-space-size=6144 dist/src/index.js &
elif [ "$FLY_PROCESS_GROUP" = "worker" ]; then 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 & exec node --max-old-space-size=3072 dist/src/services/queue-worker.js &
elif [ "$FLY_PROCESS_GROUP" = "index-worker" ]; then 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 & exec node --max-old-space-size=3072 dist/src/services/indexing/index-worker.js &
else else
echo "NO FLY PROCESS GROUP" echo "ENTRYPOINT: NO FLY PROCESS GROUP"
exec node --max-old-space-size=8192 dist/src/index.js & exec node --max-old-space-size=8192 dist/src/index.js &
fi fi
FC_PID=$! FC_PID=$!
echo "ENTRYPOINT: Background process PID: $FC_PID"
trap 'kill -SIGTERM $FC_PID; wait $FC_PID' SIGTERM 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 'kill -SIGINT $FC_PID; wait $FC_PID' SIGINT 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
trap 'kill -SIGKILL $FC_PID; wait $FC_PID' SIGKILL
echo "ENTRYPOINT: Main script waiting for PID $FC_PID..."
wait $FC_PID wait $FC_PID
echo "ALL PROCESSES TERMINATED" echo "ENTRYPOINT: All processes terminated. Script exiting."