Added config for number of gunicorn workers (#3351)
This commit is contained in:
parent
6976fe6145
commit
0c0dde127f
@ -213,6 +213,9 @@ class Config(Base):
|
|||||||
# The worker class used in production mode
|
# The worker class used in production mode
|
||||||
gunicorn_worker_class: str = "uvicorn.workers.UvicornH11Worker"
|
gunicorn_worker_class: str = "uvicorn.workers.UvicornH11Worker"
|
||||||
|
|
||||||
|
# Number of gunicorn workers from user
|
||||||
|
gunicorn_workers: Optional[int] = None
|
||||||
|
|
||||||
# Attributes that were explicitly set by the user.
|
# Attributes that were explicitly set by the user.
|
||||||
_non_default_attributes: Set[str] = pydantic.PrivateAttr(set())
|
_non_default_attributes: Set[str] = pydantic.PrivateAttr(set())
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ class Config(Base):
|
|||||||
cp_web_url: str
|
cp_web_url: str
|
||||||
username: Optional[str]
|
username: Optional[str]
|
||||||
gunicorn_worker_class: str
|
gunicorn_worker_class: str
|
||||||
|
gunicorn_workers: Optional[int]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -97,6 +98,7 @@ class Config(Base):
|
|||||||
cp_web_url: Optional[str] = None,
|
cp_web_url: Optional[str] = None,
|
||||||
username: Optional[str] = None,
|
username: Optional[str] = None,
|
||||||
gunicorn_worker_class: Optional[str] = None,
|
gunicorn_worker_class: Optional[str] = None,
|
||||||
|
gunicorn_workers: Optional[int] = None,
|
||||||
**kwargs
|
**kwargs
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
@property
|
@property
|
||||||
|
@ -217,8 +217,12 @@ def run_backend_prod(
|
|||||||
"""
|
"""
|
||||||
from reflex.utils import processes
|
from reflex.utils import processes
|
||||||
|
|
||||||
num_workers = processes.get_num_workers()
|
|
||||||
config = get_config()
|
config = get_config()
|
||||||
|
num_workers = (
|
||||||
|
processes.get_num_workers()
|
||||||
|
if not config.gunicorn_workers
|
||||||
|
else config.gunicorn_workers
|
||||||
|
)
|
||||||
RUN_BACKEND_PROD = f"gunicorn --worker-class {config.gunicorn_worker_class} --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()
|
RUN_BACKEND_PROD_WINDOWS = f"uvicorn --timeout-keep-alive {config.timeout}".split()
|
||||||
app_module = f"reflex.app_module_for_backend:{constants.CompileVars.APP}"
|
app_module = f"reflex.app_module_for_backend:{constants.CompileVars.APP}"
|
||||||
|
Loading…
Reference in New Issue
Block a user