Expose gunicorn_worker_class via Config ()

This commit is contained in:
Masen Furer 2023-10-31 13:45:29 -07:00 committed by GitHub
parent 5e2ce46ddb
commit 8eb68a006e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -198,6 +198,9 @@ class Config(Base):
# The username.
username: Optional[str] = None
# The worker class used in production mode
gunicorn_worker_class: str = "uvicorn.workers.UvicornH11Worker"
# Attributes that were explicitly set by the user.
_non_default_attributes: Set[str] = pydantic.PrivateAttr(set())

View File

@ -69,6 +69,7 @@ class Config(Base):
cp_backend_url: str
cp_web_url: str
username: Optional[str]
gunicorn_worker_class: str
def __init__(
self,
@ -95,6 +96,7 @@ class Config(Base):
cp_backend_url: Optional[str] = None,
cp_web_url: Optional[str] = None,
username: Optional[str] = None,
gunicorn_worker_class: Optional[str] = None,
**kwargs
) -> None: ...
@staticmethod

View File

@ -185,7 +185,7 @@ def run_backend_prod(
"""
num_workers = processes.get_num_workers()
config = get_config()
RUN_BACKEND_PROD = f"gunicorn --worker-class uvicorn.workers.UvicornH11Worker --preload --timeout {config.timeout} --log-level critical".split()
RUN_BACKEND_PROD = f"gunicorn --worker-class {config.gunicorn_worker_class} --preload --timeout {config.timeout} --log-level critical".split()
RUN_BACKEND_PROD_WINDOWS = f"uvicorn --timeout-keep-alive {config.timeout}".split()
app_module = f"{config.app_name}.{config.app_name}:{constants.CompileVars.APP}"
command = (