Files
ragflow_python/asr-monitor-test/run_app.sh

75 lines
1006 B
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
# 1. 终止占用9580端口的进程
PORT=9580
echo "➜ 正在检查端口 ${PORT} 的占用情况..."
PID=$(lsof -ti :${PORT})
if [ -n "$PID" ]; then
echo "➜ 发现占用端口的进程(PID: ${PID}),正在终止..."
kill -9 $PID
sleep 2 # 等待进程完全终止
echo "✓ 已终止进程"
else
echo "✓ 端口 ${PORT} 未被占用"
fi
# 2. 激活虚拟环境并设置PYTHONPATH
source venv/bin/activate
export PYTHONPATH=.:$PYTHONPATH
# 3. 使用nohup运行并防止终端退出影响
echo "➜ 启动应用进程..."
nohup python app/main.py > app.log 2>&1 &
# 4. 验证新进程
sleep 3 # 等待进程启动
NEW_PID=$(lsof -ti :${PORT})
if [ -n "$NEW_PID" ]; then
echo "✓ 应用启动成功PID: ${NEW_PID}"
echo "➜ 日志输出已重定向到 app.log"
echo "➜ 使用以下命令查看日志:"
echo " tail -f app.log"
else
echo "✗ 应用启动失败,请检查日志"
exit 1
fi