pr-agent / docker /start.sh
arasuezofis's picture
Increase API proxy timeout and wait for uvicorn on startup
e498ca8
Raw
History Blame Contribute Delete
445 Bytes
#!/bin/sh
set -e
export UNSPSC_DB_PATH="${UNSPSC_DB_PATH:-/app/data/unspsc.db}"
cd /app
uvicorn server.main:app --host 127.0.0.1 --port 8000 &
# Wait for API before nginx serves /api (avoids 502/504 on cold start)
i=0
while [ "$i" -lt 60 ]; do
if python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/api/health', timeout=2)" 2>/dev/null; then
break
fi
i=$((i + 1))
sleep 1
done
exec nginx -g "daemon off;"