Make gunicorn recycling opt-in via serve --gunicorn, fix ECS crash-loop#6
Merged
Merged
Conversation
Copilot created this pull request from a session on behalf of
galuszkm
July 7, 2026 21:53
View session
Copilot
AI
changed the title
Serve with gunicorn + recycling uvicorn worker on Linux, avoid ECS task crashes
Make gunicorn recycling opt-in via Jul 7, 2026
serve --gunicorn, fix ECS crash-loop
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Production process manager (gunicorn)
Plain
uvicorn(serveCLI) 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 aftermax_requests(default 1000 ± 100 jitter) without killing the container, and replaces crashed workers automatically. TheserveCLI is left as plain uvicorn for local development only — no process manager needed there.A new
gunicorn.conf.pyships in the docker example with all tunable knobs driven by env vars, so no image rebuild is needed to tune a deployment.Note:
gunicornis shipped as a dependency but intentionally kept out of the CLI — serve remains a plain uvicorn process (withoutlimit_max_requests, since memory leaks are not a concern in local dev) and users are expected to invoke gunicorn directly in production, tuninggunicorn.conf.pyto their own needs as shown in example 2.Related Issues
N/A
Type of Change
Testing
How have you tested the change?
uv run just check(lint + type check)uv run just testfor overall testingexamples/still workChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.