From 10dfd916a42bdca6c0e2fe34acf4542b6f8ae4a6 Mon Sep 17 00:00:00 2001 From: Wenjing Yu Date: Sat, 16 May 2026 10:55:05 -0700 Subject: [PATCH] Revert "Tune gunicorn lifecycle for streaming requests (#101)" This reverts commit db6c9f5f0ba681d48357845c906742e24780f765. --- Dockerfile | 4 ++-- gunicorn_conf.py | 21 --------------------- 2 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 gunicorn_conf.py diff --git a/Dockerfile b/Dockerfile index 8cfa199..7765628 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,5 +49,5 @@ USER nobody # Expose port EXPOSE 8000 -# Use Gunicorn config so worker lifecycle settings are explicit and env-overridable. -CMD ["gunicorn", "app.main:app", "--config", "gunicorn_conf.py"] +# Use environment variable for workers count and optimize for database connections +CMD ["sh", "-c", "gunicorn app.main:app -k uvicorn.workers.UvicornWorker --workers ${WORKERS:-5} --bind 0.0.0.0:8000 --timeout 120 --max-requests 1000 --max-requests-jitter 100"] diff --git a/gunicorn_conf.py b/gunicorn_conf.py deleted file mode 100644 index 239a136..0000000 --- a/gunicorn_conf.py +++ /dev/null @@ -1,21 +0,0 @@ -import os - - -def _int_env(name: str, default: int) -> int: - value = os.getenv(name) - if value is None or value == "": - return default - return int(value) - - -bind = f"0.0.0.0:{os.getenv('PORT', '8000')}" -worker_class = "uvicorn.workers.UvicornWorker" -workers = _int_env("WORKERS", 5) - -# Long provider streams should not be interrupted by the default 30s graceful -# shutdown window, and workers should not recycle while streaming requests run. -timeout = _int_env("GUNICORN_TIMEOUT", 300) -graceful_timeout = _int_env("GUNICORN_GRACEFUL_TIMEOUT", 300) -keepalive = _int_env("GUNICORN_KEEPALIVE", 75) -max_requests = _int_env("GUNICORN_MAX_REQUESTS", 0) -max_requests_jitter = _int_env("GUNICORN_MAX_REQUESTS_JITTER", 0)