修复登录任务无限重试导致文件描述符耗尽问题

1. docker-compose.yml:增加文件描述符限制 ulimits (65536)
2. login_service.py:限制最大重试次数为 10 次,避免无限重试
3. 解决 [Errno 24] Too many open files 错误
This commit is contained in:
yml2213
2026-06-25 06:58:18 +08:00
parent a4b04e7733
commit b9481d49ee
2 changed files with 8 additions and 1 deletions
+5
View File
@@ -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
+3 -1
View File
@@ -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