Archived
@@ -18,32 +18,37 @@ jobs:
|
|||||||
|
|
||||||
- name: 远程执行部署
|
- name: 远程执行部署
|
||||||
run: |
|
run: |
|
||||||
ssh -i ~/.ssh/deploy_key ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << EOF
|
ssh -i ~/.ssh/deploy_key ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} <<-'EOF'
|
||||||
set -e
|
set -e
|
||||||
cd ${{ secrets.DEPLOY_PATH }}
|
cd $DEPLOY_PATH
|
||||||
git config --global --add safe.directory ${{ secrets.DEPLOY_PATH }}
|
git config --global --add safe.directory $DEPLOY_PATH
|
||||||
git fetch origin main
|
git fetch origin main
|
||||||
|
|
||||||
# 备份运行时db快照
|
# 备份运行时db
|
||||||
if [ -f data/miniapp_v3.db ]; then
|
if [ -f data/miniapp_v3.db ]; then
|
||||||
cp data/miniapp_v3.db data/miniapp_v3.db.tmp
|
cp data/miniapp_v3.db data/miniapp_v3.db.tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 检出远端main全部文件(含git里的db)
|
|
||||||
git checkout origin/main -- .
|
git checkout origin/main -- .
|
||||||
|
|
||||||
# 判断本次提交是否更新了db
|
CHANGED=$(git diff --name-only HEAD FETCH_HEAD | grep "data/miniapp_v3.db" || true)
|
||||||
CHANGED=\$(git diff --name-only HEAD FETCH_HEAD | grep "data/miniapp_v3.db" || true)
|
if [ -z "$CHANGED" ]; then
|
||||||
if [ -z "\$CHANGED" ]; then
|
|
||||||
# git未更新db:恢复服务器运行时的db
|
|
||||||
if [ -f data/miniapp_v3.db.tmp ]; then
|
if [ -f data/miniapp_v3.db.tmp ]; then
|
||||||
cp data/miniapp_v3.db.tmp data/miniapp_v3.db
|
cp data/miniapp_v3.db.tmp data/miniapp_v3.db
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f data/miniapp_v3.db.tmp
|
rm -f data/miniapp_v3.db.tmp
|
||||||
|
|
||||||
/www/server/pyporject_evn/versions/3.12.13/bin/pip install -r requirements.txt
|
/www/server/pyporject_evn/versions/3.12.13/bin/pip install -r requirements.txt
|
||||||
chown -R www:www .
|
chown -R www:www .
|
||||||
/www/server/panel/pyenv/bin/python3 /www/server/panel/plugin/python/project.py restart Hulumath-Web-Demo
|
|
||||||
|
# 获取gunicorn master进程,发送HUP优雅重载
|
||||||
|
MASTER_PID=$(pgrep -f "gunicorn_conf.py" -P 1)
|
||||||
|
echo "Detected gunicorn master PID: $MASTER_PID"
|
||||||
|
if [ -n "$MASTER_PID" ]; then
|
||||||
|
kill -HUP "$MASTER_PID"
|
||||||
|
echo "✅ Graceful reload signal sent"
|
||||||
|
else
|
||||||
|
echo "⚠️ Gunicorn master not found, skip reload"
|
||||||
|
fi
|
||||||
EOF
|
EOF
|
||||||
Reference in New Issue
Block a user