chore(tradein): drop uvicorn --reload in prod (WatchFiles overhead) #641

Merged
Light1YT merged 1 commit from chore/tradein-prod-no-uvicorn-reload into main 2026-05-29 08:32:35 +00:00
Owner

Summary

Prod backend ran uvicorn with --reload (Dockerfile CMD carries it for dev hot-reload; prod uses the same image). Prod logs showed Started reloader process [1] using WatchFiles — a wasted file-watcher + risk of reload mid-request on an immutable image.

Add a prod-only command: override (docker-compose.prod.yml backend service) running uvicorn WITHOUT --reload. Single worker kept (no --workers) — the in-app scheduler (app.services.scheduler, tick=60s) lives in the backend process; multiple workers would duplicate scheduled jobs (cian/rosreestr would fire N times). Dev untouched (no command override there → inherits Dockerfile --reload via app/ bind-mount).

Verification done

  • YAML parses; backend.command = [uvicorn, app.main:app, --host 0.0.0.0, --port 8000]
  • dev docker-compose.yml has NO command override → keeps --reload
  • prod has only postgres/backend/frontend (backend = only uvicorn svc → no dup-scheduler)
  • Post-merge: backend starts, NO Started reloader process in logs, scheduler: started appears once, /health 200

Found while verifying the #638/#640 deploys (flagged as a side-note).

## Summary Prod backend ran uvicorn with `--reload` (Dockerfile CMD carries it for dev hot-reload; prod uses the same image). Prod logs showed `Started reloader process [1] using WatchFiles` — a wasted file-watcher + risk of reload mid-request on an immutable image. Add a **prod-only `command:` override** (docker-compose.prod.yml backend service) running uvicorn WITHOUT `--reload`. **Single worker kept (no --workers)** — the in-app scheduler (`app.services.scheduler`, tick=60s) lives in the backend process; multiple workers would duplicate scheduled jobs (cian/rosreestr would fire N times). Dev untouched (no command override there → inherits Dockerfile `--reload` via app/ bind-mount). ## Verification done - [x] YAML parses; `backend.command = [uvicorn, app.main:app, --host 0.0.0.0, --port 8000]` - [x] dev docker-compose.yml has NO command override → keeps --reload - [x] prod has only postgres/backend/frontend (backend = only uvicorn svc → no dup-scheduler) - [ ] Post-merge: backend starts, NO `Started reloader process` in logs, `scheduler: started` appears once, /health 200 Found while verifying the #638/#640 deploys (flagged as a side-note).
Light1YT added 1 commit 2026-05-29 08:32:24 +00:00
Dockerfile CMD carries `--reload` for dev hot-reload (app/ bind-mounted in
docker-compose.yml). In prod the same image ran with --reload too — prod logs
showed "Started reloader process [1] using WatchFiles" — wasting a file-watcher
and risking a reload mid-request on an immutable image.

Add a prod-only `command:` override running uvicorn without --reload. Keep it a
single worker (no --workers): the in-app scheduler (app.services.scheduler,
tick=60s) lives in the backend process, so multiple workers would duplicate
scheduled jobs (cian/rosreestr would fire N times). Dev is untouched (no command
override there → still inherits the Dockerfile --reload).
Light1YT merged commit 097c69e6d7 into main 2026-05-29 08:32:35 +00:00
Light1YT deleted branch chore/tradein-prod-no-uvicorn-reload 2026-05-29 08:32:35 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#641
No description provided.