Skip to content

Commit fe7577d

Browse files
author
yihuiwen
committed
add keep alive params in gunicorn
1 parent 739a1ca commit fe7577d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lightllm/server/api_start.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .visualserver.manager import start_visual_process
1212
from lightllm.utils.log_utils import init_logger
1313
from lightllm.utils.envs_utils import set_env_start_args, set_unique_server_name, get_unique_server_name
14-
from lightllm.utils.envs_utils import get_lightllm_gunicorn_time_out_seconds
14+
from lightllm.utils.envs_utils import get_lightllm_gunicorn_time_out_seconds, get_lightllm_gunicorn_keep_alive
1515
from .detokenization.manager import start_detokenization_process
1616
from .router.manager import start_router_process
1717
from lightllm.utils.process_check import is_process_active
@@ -260,6 +260,8 @@ def normal_or_p_d_start(args):
260260
"lightllm.server.api_http:app",
261261
"--timeout",
262262
f"{get_lightllm_gunicorn_time_out_seconds()}",
263+
"--keep-alive",
264+
f"{get_lightllm_gunicorn_keep_alive()}",
263265
]
264266

265267
# 启动子进程
@@ -327,6 +329,8 @@ def pd_master_start(args):
327329
"lightllm.server.api_http:app",
328330
"--timeout",
329331
f"{get_lightllm_gunicorn_time_out_seconds()}",
332+
"--keep-alive",
333+
f"{get_lightllm_gunicorn_keep_alive()}",
330334
]
331335

332336
http_server_process = subprocess.Popen(command)
@@ -367,6 +371,8 @@ def config_server_start(args):
367371
"lightllm.server.config_server.api_http:app",
368372
"--timeout",
369373
f"{get_lightllm_gunicorn_time_out_seconds()}",
374+
"--keep-alive",
375+
f"{get_lightllm_gunicorn_keep_alive()}",
370376
]
371377

372378
http_server_process = subprocess.Popen(command)

lightllm/utils/envs_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def get_lightllm_gunicorn_time_out_seconds():
6262
return int(os.getenv("LIGHTLMM_GUNICORN_TIME_OUT", 180))
6363

6464

65+
def get_lightllm_gunicorn_keep_alive():
66+
return int(os.getenv("LIGHTLMM_GUNICORN_KEEP_ALIVE", 10))
67+
68+
6569
@lru_cache(maxsize=None)
6670
def get_lightllm_websocket_max_message_size():
6771
"""

0 commit comments

Comments
 (0)