Files
aitsc/scripts/stop_gunicorn.sh

49 lines
1.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
echo "🛑 停止Gunicorn服务..."
echo "=========================================="
# 进入项目目录
cd /home/renjianbo/aitsc
# 检查PID文件是否存在
if [ -f "logs/gunicorn.pid" ]; then
PID=$(cat logs/gunicorn.pid)
echo "📋 找到Gunicorn进程PID: $PID"
# 检查进程是否存在
if ps -p $PID > /dev/null; then
echo "🔄 正在停止进程..."
kill -TERM $PID
# 等待进程停止
sleep 3
# 检查是否成功停止
if ps -p $PID > /dev/null; then
echo "⚠️ 进程仍在运行,强制停止..."
kill -9 $PID
fi
echo "✅ Gunicorn服务已停止"
else
echo "⚠️ 进程不存在,可能已经停止"
fi
else
echo "⚠️ 未找到PID文件尝试查找进程..."
# 查找Gunicorn进程
PIDS=$(ps aux | grep gunicorn | grep -v grep | awk '{print $2}')
if [ -n "$PIDS" ]; then
echo "📋 找到Gunicorn进程: $PIDS"
echo $PIDS | xargs kill -TERM
sleep 3
echo "✅ Gunicorn服务已停止"
else
echo " 未找到运行中的Gunicorn进程"
fi
fi
echo "=========================================="