feat(api): add gunicorn with uvicorn workers for production deployment#69
Conversation
- Add gunicorn as a dependency with uvicorn worker class support - Create entrypoint-api.sh script for configurable worker count - Add API_WORKERS env variable to control worker processes - Update Dockerfile.api to use gunicorn entrypoint in production - Ensure justfile commands use uv run consistently - Remove deprecated version field from docker-compose.prod.yml - Add PYTHONUNBUFFERED=1 for proper logging in containers - Update README with uv run prefixes for all commands Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR #69 Review: feat(api): add gunicorn with uvicorn workers for production deploymentGood direction — gunicorn + UvicornWorker is the standard ASGI production pattern. The housekeeping (removing deprecated 🔴 CRITICAL — Must Fix Before Merge1. Gunicorn factory pattern: missing parentheses → API won't start
exec uv run gunicorn src.presentation.api.app:create_app \Gunicorn does not have a Fix: exec uv run gunicorn "src.presentation.api.app:create_app()" \Quotes are required because 2.
|
Add gunicorn as the WSGI server with uvicorn workers for production API deployment. This provides better performance, worker process management, and graceful restarts compared to running uvicorn directly.
Type of Change
Changes Summary
pyproject.tomlwith uvicorn worker class supportentrypoint-api.shscript for containerized gunicorn startup with configurable worker countAPI_WORKERSenvironment variable (defaults to 4) for controlling worker processesDockerfile.apito use the new entrypoint script and install without dev dependenciesjustfilecommands to useuv runconsistently across all tasks.github/README.mdwith correctuv runprefixes for all commandsversionfield fromdocker-compose.prod.ymlPYTHONUNBUFFERED=1in Dockerfile for proper logging in containersTesting
API_WORKERSsettinguv runprefixCode Quality
pre-commit run --all-files)Related Issues
Related to production deployment improvements.
Additional Notes
The entrypoint script provides sensible defaults:
API_WORKERSenv var (defaults to 4 workers)--preloadfor faster worker startup and memory efficiencyuvicorn.workers.UvicornWorkerfor ASGI compatibilityMigration: Update
.envfile to includeAPI_WORKERS=4(or desired count) for production deployments.Checklist for Reviewers:
🤖 Generated with Claude Code