You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should configure GCP to wait to run readiness checks until the API is actually ready
We should add definitive logging at particular points within the launch script (I believe we also have to specify specifically to log to stdout)
We should ensure that after doing so, the logs actually appear within the GCP console
Here are some modifications that Claude recommended, but I haven't proofed them:
#!/bin/sh
# Environment variables
PORT="${PORT:-8080}"
WORKER_COUNT="${WORKER_COUNT:-3}"
REDIS_PORT="${REDIS_PORT:-6379}"
echo "Starting API server..." >&2
# Start the API
gunicorn -b :"$PORT" policyengine_api.api --timeout 300 --workers 5 &
API_PID=$!
# Wait for API to be ready (try connecting to the port)
TIMEOUT=30
while [ $TIMEOUT -gt 0 ]; do
if nc -z localhost "$PORT"; then
echo "API server is ready" >&2
break
fi
TIMEOUT=$((TIMEOUT - 1))
sleep 1
done
if [ $TIMEOUT -eq 0 ]; then
echo "API server failed to start" >&2
exit 1
fi
echo "Starting Redis..." >&2
# Start Redis with configuration for multiple clients
redis-server --protected-mode no \
--maxclients 10000 \
--timeout 0 &
REDIS_PID=$!
# Wait for Redis to be ready
sleep 2
# Start multiple workers using POSIX-compliant loop
i=1
while [ $i -le "$WORKER_COUNT" ]
do
echo "Starting worker $i..." >&2
python3 policyengine_api/worker.py &
i=$((i + 1))
done
# Keep the script running and handle shutdown gracefully
trap "kill $API_PID $REDIS_PID; pkill -P $$; exit 1" INT TERM
wait
The text was updated successfully, but these errors were encountered:
A few things:
Here are some modifications that Claude recommended, but I haven't proofed them:
The text was updated successfully, but these errors were encountered: