auto_trade_sys/backend/stop.sh
薇薇安 449ad01ede a
2026-02-03 09:49:25 +08:00

24 lines
554 B
Bash
Raw Permalink 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
# 停止后端服务脚本
cd "$(dirname "$0")"
# 查找运行中的uvicorn进程
PID=$(ps aux | grep "uvicorn api.main:app" | grep -v grep | awk '{print $2}')
if [ -z "$PID" ]; then
echo "未找到运行中的后端服务"
else
echo "找到运行中的后端服务PID: $PID"
echo "正在停止服务..."
kill $PID
sleep 1
# 检查是否成功停止
if ps -p $PID > /dev/null 2>&1; then
echo "停止失败,尝试强制停止..."
kill -9 $PID
fi
echo "后端服务已停止"
fi