Files
AIRegulation-DocAnalysis/stop_api.sh
2026-05-14 15:07:34 +08:00

47 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
# stop_api.sh - 停止API服务
PID_FILE=logs/api.pid
echo "========================================"
echo "停止 AI+合规智能中枢 API服务"
echo "========================================"
echo ""
if [ -f "$PID_FILE" ]; then
PID=$(cat $PID_FILE)
if ps -p $PID > /dev/null 2>&1; then
echo "正在停止服务 (PID: $PID)..."
kill $PID
# 等待进程结束
sleep 2
if ps -p $PID > /dev/null 2>&1; then
echo "进程未响应,强制终止..."
kill -9 $PID
fi
rm -f $PID_FILE
echo "服务已停止"
else
echo "进程已不存在清理PID文件"
rm -f $PID_FILE
fi
else
echo "PID文件不存在服务可能未运行"
# 尝试查找并停止所有uvicorn进程
UVICORN_PIDS=$(pgrep -f "uvicorn app.main:app")
if [ -n "$UVICORN_PIDS" ]; then
echo "发现运行中的uvicorn进程: $UVICORN_PIDS"
echo "是否停止这些进程? (y/n)"
read -r answer
if [ "$answer" = "y" ]; then
kill $UVICORN_PIDS
echo "进程已停止"
fi
fi
fi