fix: 降低 gthread 连接数防 MySQL 打满 + 最终一键修复脚本

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-09 05:12:23 +08:00
parent ad63b3f1ee
commit 01ffbdf478
2 changed files with 85 additions and 8 deletions

View File

@@ -1,11 +1,10 @@
# Gunicorn 生产配置systemd 与 1Panel 共用此文件,勿再手写冲突参数
# 安装后: systemctl restart gunicorn-dianjing.service
# Gunicorn 生产配置systemd 与 1Panel 共用)
# 远程 MySQL 时 worker×threads 不宜过大,否则打满 DB 连接 → 全站挂起
bind = "127.0.0.1:8001"
# 必须用 gthreadsync 模式下 4 worker 同时只能处理 4 个请求,远程 MySQL 一慢就全站卡死
workers = 6
threads = 4
workers = 4
threads = 2
worker_class = "gthread"
timeout = 120
@@ -15,12 +14,9 @@ keepalive = 2
max_requests = 2000
max_requests_jitter = 100
# 禁止输出到 stdout/stderr曾灌满 journal 导致整机卡)
accesslog = None
errorlog = "/tmp/gunicorn-error.log"
loglevel = "warning"
# gthread + MySQL 连接池preload 易在 fork 后出连接问题
preload_app = False
proc_name = "a_long_dianjing_gunicorn"