Skip to content

Make gunicorn recycling opt-in via serve --gunicorn, fix ECS crash-loop#6

Merged
galuszkm merged 4 commits into
mainfrom
copilot/implement-gunicorn-uvicorn-settings
Jul 8, 2026
Merged

Make gunicorn recycling opt-in via serve --gunicorn, fix ECS crash-loop#6
galuszkm merged 4 commits into
mainfrom
copilot/implement-gunicorn-uvicorn-settings

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

Production process manager (gunicorn)
Plain uvicorn (serve CLI) has no process manager — when the process exits (OOM, request limit hit), the container dies and the ALB/ECS health check fails.
To safely run on small Fargate tasks (0.25 vCPU / 512 MB) where memory leaks accumulate, the docker example now runs under gunicorn with a uvicorn_worker.UvicornWorker. Gunicorn recycles the worker after max_requests (default 1000 ± 100 jitter) without killing the container, and replaces crashed workers automatically. The serve CLI is left as plain uvicorn for local development only — no process manager needed there.

A new gunicorn.conf.py ships in the docker example with all tunable knobs driven by env vars, so no image rebuild is needed to tune a deployment.

Note: gunicorn is shipped as a dependency but intentionally kept out of the CLI — serve remains a plain uvicorn process (without limit_max_requests, since memory leaks are not a concern in local dev) and users are expected to invoke gunicorn directly in production, tuning gunicorn.conf.py to their own needs as shown in example 2.

Related Issues

N/A

Type of Change

  • Bug fix
  • New feature

Testing

How have you tested the change?

  • I ran uv run just check (lint + type check)
  • I ran uv run just test for overall testing
  • I added or updated tests that prove my fix is effective or my feature works
  • I verified existing examples in examples/ still work

Checklist

  • I have read the CONTRIBUTING document
  • I have updated the documentation accordingly
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copilot AI changed the title Serve with gunicorn + recycling uvicorn worker on Linux, avoid ECS task crashes Make gunicorn recycling opt-in via serve --gunicorn, fix ECS crash-loop Jul 7, 2026
Copilot AI requested a review from galuszkm July 7, 2026 22:13
galuszkm added 2 commits July 8, 2026 21:43
- fix sqladmin 0.28 method signature breakage on get_list_value/get_detail_value
- remove gunicorn from CLI; serve is plain uvicorn for dev only
- run docker example under gunicorn with worker recycling via gunicorn.conf.py
- set HOME and TMPDIR to /tmp for rootless container compatibility
- document read-only root filesystem / writable /tmp requirements for ECS Fargate
- replace Tuple[Any, Any] with native tuple in chat_session admin view
@galuszkm galuszkm marked this pull request as ready for review July 8, 2026 19:54

@galuszkm galuszkm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@galuszkm galuszkm merged commit 844de33 into main Jul 8, 2026
8 checks passed
@galuszkm galuszkm deleted the copilot/implement-gunicorn-uvicorn-settings branch July 8, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants