Windows production mode command (#570)

This commit is contained in:
PeterYusuke 2023-02-22 03:42:10 +09:00 committed by GitHub
parent 977cc6990f
commit f7a5c99969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 8 deletions

View File

@ -77,6 +77,7 @@ BACKEND_HOST = "0.0.0.0"
TIMEOUT = 120
# The command to run the backend in production mode.
RUN_BACKEND_PROD = f"gunicorn --worker-class uvicorn.workers.UvicornH11Worker --preload --timeout {TIMEOUT} --log-level critical".split()
RUN_BACKEND_PROD_WINDOWS = f"uvicorn --timeout-keep-alive {TIMEOUT}".split()
# Compiler variables.
# The extension for compiled Javascript files.

View File

@ -799,16 +799,33 @@ def run_backend_prod(
setup_backend()
num_workers = get_num_workers()
command = constants.RUN_BACKEND_PROD + [
"--bind",
f"0.0.0.0:{port}",
command = (
constants.RUN_BACKEND_PROD_WINDOWS
+ [
"--host",
"0.0.0.0",
"--port",
str(port),
"--log-level",
loglevel,
f"{app_name}:{constants.APP_VAR}",
]
if platform.system() == "Windows"
else constants.RUN_BACKEND_PROD
+ [
"--bind",
f"0.0.0.0:{port}",
"--threads",
str(num_workers),
"--log-level",
str(loglevel),
f"{app_name}:{constants.APP_VAR}()",
]
)
command += [
"--workers",
str(num_workers),
"--threads",
str(num_workers),
"--log-level",
str(loglevel),
f"{app_name}:{constants.APP_VAR}()",
]
subprocess.run(command)