Files
Django/deploy/apply-lag-fix.sh

37 lines
1.3 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
# 部署卡顿修复并验证 rt=
set -e
DJANGO_DIR="/opt/1panel/apps/openresty/nginx/www/sites/43.142.166.152.443/django"
NGINX_LOG="/opt/1panel/apps/openresty/nginx/log/access.log"
cd "$DJANGO_DIR"
echo ">>> git pull"
git pull origin main
echo ">>> 更新 systemd (6 workers)"
cp deploy/systemd/gunicorn-dianjing.service /etc/systemd/system/gunicorn-dianjing.service
systemctl daemon-reload
systemctl restart gunicorn-dianjing.service
sleep 2
systemctl is-active gunicorn-dianjing.service
pgrep -cf 'gunicorn.*a_long_dianjing' || true
echo ""
echo ">>> 安装 worker 保活 cron空闲后不卡"
chmod +x deploy/gunicorn-warmup.sh
cp deploy/gunicorn-warmup.cron /etc/cron.d/gunicorn-warmup
chmod 644 /etc/cron.d/gunicorn-warmup
bash deploy/gunicorn-warmup.sh
echo " cron 已安装每2分钟预热 worker"
echo ""
echo ">>> 最近慢请求 (rt>=0.5s):"
grep -a 'hqhd' "$NGINX_LOG" | awk 'match($0,/rt=([0-9.]+)/,a){if(a[1]+0>=0.5)print}' | tail -5
echo ""
echo ">>> 最近 dddhq / merchant-staff/me:"
grep -a 'hqhd' "$NGINX_LOG" | grep -E 'ddhq|merchant-staff/me' | tail -8 | awk 'match($0,/rt=([0-9.]+)/,a){rt=a[1]} match($0,/POST ([^ ]+)/,b){print " rt="rt"s "b[1]}'
echo ""
echo "部署完成。请用手机再试,然后看上面 rt 是否都 <0.2s"