From ac06d78f6e47a06ddda99e06f5ccca6b092f7134 Mon Sep 17 00:00:00 2001 From: Michael Bunsen Date: Fri, 20 Feb 2026 16:57:06 -0800 Subject: [PATCH] feat: add WEB_WORKERS env var for configurable worker counts Local dev: WEB_WORKERS > 1 runs uvicorn with --workers (no --reload). Default single-worker mode keeps --reload for hot reloading. Production: explicit --workers for gunicorn (defaults to 4). Co-Authored-By: Claude --- compose/local/django/start | 8 +++++++- compose/production/django/start | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compose/local/django/start b/compose/local/django/start index 4eaa76436..252b99752 100755 --- a/compose/local/django/start +++ b/compose/local/django/start @@ -11,5 +11,11 @@ python manage.py migrate if [ "${DEBUGGER:-0}" = "1" ]; then exec python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678 -m uvicorn config.asgi:application --host 0.0.0.0 else - exec uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html' + WORKERS="${WEB_WORKERS:-1}" + if [ "$WORKERS" -gt 1 ]; then + # --reload is incompatible with --workers, so skip it for multi-worker mode + exec uvicorn config.asgi:application --host 0.0.0.0 --workers "$WORKERS" + else + exec uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html' + fi fi diff --git a/compose/production/django/start b/compose/production/django/start index 5dcb00b5a..a775c0527 100644 --- a/compose/production/django/start +++ b/compose/production/django/start @@ -6,4 +6,6 @@ set -o nounset python /app/manage.py collectstatic --noinput -exec newrelic-admin run-program /usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:5000 --chdir=/app -k uvicorn.workers.UvicornWorker +exec newrelic-admin run-program /usr/local/bin/gunicorn config.asgi \ + --workers "${WEB_WORKERS:-4}" \ + --bind 0.0.0.0:5000 --chdir=/app -k uvicorn.workers.UvicornWorker