From d179ce1cd45cd43f31ca64203625078bc9c81846 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Mon, 9 Jun 2025 10:41:21 +0800 Subject: [PATCH] perf: Add celery worker count config --- apps/common/management/commands/services/hands.py | 1 + .../management/commands/services/services/celery_base.py | 4 ++-- apps/i18n/luna/en.json | 3 ++- apps/i18n/luna/zh.json | 3 ++- apps/jumpserver/conf.py | 1 + apps/jumpserver/settings/custom.py | 1 + 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/common/management/commands/services/hands.py b/apps/common/management/commands/services/hands.py index c2e625e8b..fb289aea4 100644 --- a/apps/common/management/commands/services/hands.py +++ b/apps/common/management/commands/services/hands.py @@ -25,3 +25,4 @@ BASE_DIR = os.path.dirname(settings.BASE_DIR) LOG_DIR = os.path.join(BASE_DIR, 'data', 'logs') APPS_DIR = os.path.join(BASE_DIR, 'apps') TMP_DIR = os.path.join(BASE_DIR, 'tmp') +CELERY_WORKER_COUNT = CONFIG.CELERY_WORKER_COUNT or 10 diff --git a/apps/common/management/commands/services/services/celery_base.py b/apps/common/management/commands/services/services/celery_base.py index b8e42fed4..5d6878a2a 100644 --- a/apps/common/management/commands/services/services/celery_base.py +++ b/apps/common/management/commands/services/services/celery_base.py @@ -4,10 +4,10 @@ from ..hands import * class CeleryBaseService(BaseService): - def __init__(self, queue, num=10, **kwargs): + def __init__(self, queue, **kwargs): super().__init__(**kwargs) self.queue = queue - self.num = num + self.num = CELERY_WORKER_COUNT @property def cmd(self): diff --git a/apps/i18n/luna/en.json b/apps/i18n/luna/en.json index ad59cd256..dd4fb8f9b 100644 --- a/apps/i18n/luna/en.json +++ b/apps/i18n/luna/en.json @@ -240,5 +240,6 @@ "VerificationFailed": "Verification failed", "BatchCommands": "Batch commands", "SendCommandPlaceholder": "Input command here..., Enter for new line, Ctrl+Enter to send", - "SelectCommand": "Please select the command to execute." + "SelectCommand": "Please select the command to execute.", + "ConnectSessionCount": "{{ count }} sessions connected" } \ No newline at end of file diff --git a/apps/i18n/luna/zh.json b/apps/i18n/luna/zh.json index 00314fdb3..ac8ff85c0 100644 --- a/apps/i18n/luna/zh.json +++ b/apps/i18n/luna/zh.json @@ -238,5 +238,6 @@ "Send": "发送", "BatchCommands": "批量命令", "SendCommandPlaceholder": "输入命令,回车换行,Ctrl+Enter 执行命令", - "SelectCommand": "请选择要执行的命令" + "SelectCommand": "请选择要执行的命令", + "ConnectSessionCount": "{{ count }} 个会话已连接" } \ No newline at end of file diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index e9c67e4f4..a42337ef3 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -623,6 +623,7 @@ class Config(dict): 'HTTP_BIND_HOST': '0.0.0.0', 'HTTP_LISTEN_PORT': 8080, 'WS_LISTEN_PORT': 8070, + 'CELERY_WORKER_COUNT': 10, 'SYSLOG_ADDR': '', # '192.168.0.1:514' 'SYSLOG_FACILITY': 'user', diff --git a/apps/jumpserver/settings/custom.py b/apps/jumpserver/settings/custom.py index 33c49913d..d9bd8257a 100644 --- a/apps/jumpserver/settings/custom.py +++ b/apps/jumpserver/settings/custom.py @@ -124,6 +124,7 @@ ASSET_PERMISSION_DEFAULT_EXPIRED_DAYS = CONFIG.ASSET_PERMISSION_DEFAULT_EXPIRED_ USER_GUIDE_URL = CONFIG.USER_GUIDE_URL HTTP_LISTEN_PORT = CONFIG.HTTP_LISTEN_PORT WS_LISTEN_PORT = CONFIG.WS_LISTEN_PORT +CELERY_WORKER_COUNT = CONFIG.CELERY_WORKER_COUNT LOGIN_LOG_KEEP_DAYS = CONFIG.LOGIN_LOG_KEEP_DAYS TASK_LOG_KEEP_DAYS = CONFIG.TASK_LOG_KEEP_DAYS OPERATE_LOG_KEEP_DAYS = CONFIG.OPERATE_LOG_KEEP_DAYS