Files
Django/deploy/safe-deploy.sh

31 lines
1.1 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
# 安全部署:只 git pull + 更新 systemd + 重启,不手动删任何路径
# 用法: bash deploy/safe-deploy.sh
set -e
DJANGO_DIR="/opt/1panel/apps/openresty/nginx/www/sites/43.142.166.152.443/django"
cd "$DJANGO_DIR"
echo ">>> git pull"
git pull origin main
echo ">>> 更新 gunicorn systemd先停再起避免 8001 双开)"
cp deploy/systemd/gunicorn-dianjing.service /etc/systemd/system/gunicorn-dianjing.service
systemctl daemon-reload
systemctl enable gunicorn-dianjing.service
systemctl stop gunicorn-dianjing.service 2>/dev/null || true
sleep 2
pkill -f 'gunicorn.*a_long_dianjing' 2>/dev/null || true
pkill -f 'gunicorn -c gunicorn.conf.py' 2>/dev/null || true
sleep 2
systemctl start gunicorn-dianjing.service
sleep 3
echo ">>> 状态"
systemctl is-active gunicorn-dianjing.service
echo "gunicorn 进程: $(pgrep -cf 'gunicorn.*a_long_dianjing' || echo 0)"
echo ""
echo "部署完成。未删除任何文件。"
echo "若需查卡顿根因(可选): bash deploy/enable-slow-trace.sh"
echo "查完关闭追踪: bash deploy/disable-slow-trace.sh"