Files
Django/deploy/audit-system.sh

44 lines
1.8 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 系统级排查Gunicorn 是否双开、是否用了错误的 sync 配置
set -e
echo "========== Gunicorn 进程(看 worker_class / 是否双开)=========="
pgrep -af gunicorn || echo "无 gunicorn"
echo ""
echo "========== 8001 端口占用 =========="
ss -ltnp 2>/dev/null | grep 8001 || netstat -ltnp 2>/dev/null | grep 8001 || echo "8001 未监听"
echo ""
echo "========== systemd 实际启动命令 =========="
systemctl cat gunicorn-dianjing.service 2>/dev/null | grep -E '^ExecStart|^Environment' || echo "无 systemd service"
echo ""
echo "========== gunicorn.conf.py 关键项 =========="
CONF="/opt/1panel/apps/openresty/nginx/www/sites/43.142.166.152.443/django/gunicorn.conf.py"
if [ -f "$CONF" ]; then
grep -E 'worker_class|workers|threads|accesslog|errorlog|preload' "$CONF" | grep -v '^#'
else
echo "找不到 $CONF"
fi
echo ""
echo "========== 判定 =========="
NG=$(pgrep -cf 'gunicorn.*a_long_dianjing' 2>/dev/null || echo 0)
if [ "$NG" -gt 8 ]; then
echo ">>> 警告: gunicorn 进程过多($NG),可能 systemd + 1Panel 双开,必须只留 systemd"
fi
RECENT=$(grep -a 'Connection in use' /tmp/gunicorn-error.log 2>/dev/null | tail -1)
if [ -n "$RECENT" ]; then
echo ">>> 警告: error.log 曾出现 8001 端口冲突(双开 gunicorn:"
echo " $RECENT"
echo " 执行: bash deploy/fix-gunicorn-8001-conflict.sh"
fi
if grep -q 'worker_class.*sync' "$CONF" 2>/dev/null; then
echo ">>> 致命: gunicorn.conf.py 仍是 sync全站会卡死必须改为 gthread 并 restart"
fi
if grep -q 'accesslog.*"-' "$CONF" 2>/dev/null || grep -q "accesslog = '-'" "$CONF" 2>/dev/null; then
echo ">>> 致命: accesslog 输出到 stdout会灌 journal 卡整机"
fi
echo ""
echo "正确做法: 1Panel 关闭 Python 自动管理 → git pull → bash deploy/safe-deploy.sh"