auto_trade_sys/backend/restart.sh
薇薇安 4140370c2d a
2026-01-14 10:57:14 +08:00

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