open-notebook/supervisord.conf
Luis Novo d6c33151ab
feat(worker): expose OPEN_NOTEBOOK_WORKER_MAX_TASKS to control worker concurrency (#1141)
The worker processes all queued tasks up to a fixed concurrency of 5, which
overloads single-GPU / local-LLM setups and triggers rate limits (#893). The
surreal-commands worker already accepts --max-tasks; wire it to a new
OPEN_NOTEBOOK_WORKER_MAX_TASKS env var (default 5, set 1 for sequential) at
every launch point.

- Makefile (worker-start, start-all): --max-tasks "$${VAR:-5}" (Make-escaped)
- dev-init.sh: POSIX ${VAR:-5} default expansion
- supervisord.conf: wrap in sh -c so the shell expands the var (command= does
  not run through a shell)
- docker-compose.yml: commented environment example
- .env.example + environment-reference.md: document it, incl. the launch-time
  sourcing behavior

Also fixes a phantom doc entry: SURREAL_COMMANDS_MAX_TASKS was documented but
is not read anywhere (the worker's --max-tasks Typer option has no envvar);
replaced with the real OPEN_NOTEBOOK_WORKER_MAX_TASKS.

Closes #893
2026-07-14 12:28:48 -03:00

50 lines
1.6 KiB
Text

# Shared supervisord configuration for both Docker image variants.
# The single-container image appends supervisord.surrealdb.conf to this file
# at build time (see the `single` stage in the Dockerfile).
[supervisord]
nodaemon=true
logfile=/dev/stdout
logfile_maxbytes=0
pidfile=/tmp/supervisord.pid
[program:api]
command=uv run --no-sync uvicorn api.main:app --host %(ENV_API_HOST)s --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]
; sh -c so the shell expands ${OPEN_NOTEBOOK_WORKER_MAX_TASKS:-5} (supervisord's
; own command= does not run through a shell). Falls back to 5 when unset.
command=sh -c "uv run --no-sync surreal-commands-worker --import-modules commands --max-tasks ${OPEN_NOTEBOOK_WORKER_MAX_TASKS:-5}"
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]
; HOSTNAME must be forced here: container runtimes inject HOSTNAME=<container/pod
; hostname> at runtime (Podman pods override the image's ENV HOSTNAME=0.0.0.0),
; making Next.js bind to the wrong address (#994). Override with FRONTEND_BIND_HOST.
command=bash -c "/app/scripts/wait-for-api.sh && HOSTNAME=${FRONTEND_BIND_HOST:-0.0.0.0} node server.js"
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