open-notebook/supervisord.single.conf
LUIS NOVO d0d5d97578 fix: wait for API to be ready before starting frontend
Users reported "Unable to Connect to API Server" errors on startup
because the frontend started before the API finished initialization
(database migrations, etc.).

- Add wait-for-api.sh script that polls /health endpoint
- Update supervisord configs to use wait script instead of sleep 5
- Waits up to 5 minutes for API to be ready before starting frontend
- Applies to both single-container and multi-container deployments

Fixes #315
2025-12-14 11:39:59 -03:00

52 lines
No EOL
1.2 KiB
Text

[supervisord]
nodaemon=true
logfile=/dev/stdout
logfile_maxbytes=0
pidfile=/tmp/supervisord.pid
[program:surrealdb]
command=surreal start --log trace --user root --pass root rocksdb:/mydata/mydatabase.db
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true
priority=5
autostart=true
startsecs=5
[program:api]
command=uv run uvicorn api.main:app --host 0.0.0.0 --port 5055
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true
priority=10
autostart=true
startsecs=3
[program:worker]
command=uv run surreal-commands-worker --import-modules commands
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true
priority=20
autostart=true
startsecs=3
[program:frontend]
command=bash -c "/app/scripts/wait-for-api.sh && npm run start"
directory=/app/frontend
environment=NODE_ENV="production",PORT="8502"
passenv=API_URL,NEXT_PUBLIC_API_URL,INTERNAL_API_URL
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true
priority=30
autostart=true
startsecs=10