From b9481d49ee5543307520d09d4a79aec0da997106 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Thu, 25 Jun 2026 06:58:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=97=A0=E9=99=90=E9=87=8D=E8=AF=95=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=8F=8F=E8=BF=B0=E7=AC=A6=E8=80=97=E5=B0=BD?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. docker-compose.yml:增加文件描述符限制 ulimits (65536) 2. login_service.py:限制最大重试次数为 10 次,避免无限重试 3. 解决 [Errno 24] Too many open files 错误 --- docker-compose.yml | 5 +++++ web/backend/services/login_service.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index e9242e7..18f53e3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,11 @@ services: - MAIL_ROUNDCUBE_URL=${MAIL_ROUNDCUBE_URL:-} # Uvicorn reload(生产环境保持 false) - UVICORN_RELOAD=${UVICORN_RELOAD:-false} + # 增加文件描述符限制,避免 "Too many open files" 错误 + ulimits: + nofile: + soft: 65536 + hard: 65536 healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')"] interval: 30s diff --git a/web/backend/services/login_service.py b/web/backend/services/login_service.py index e57dac6..22e17e6 100644 --- a/web/backend/services/login_service.py +++ b/web/backend/services/login_service.py @@ -38,7 +38,9 @@ class LoginBatchRunner: self.created_by = created_by self.creator_permissions = creator_permissions self.max_proxy_retries = max_proxy_retries - self.max_login_retries = max_login_retries + # 限制最大重试次数,避免无限重试导致资源耗尽 + # 0 表示使用默认值 10,其他值保持原样 + self.max_login_retries = max_login_retries if max_login_retries > 0 else 10 self.max_total_time = max_total_time self.proxy_config = proxy_config self.log_queue = log_queue