auto_trade_sys/backend/start_recommendations.sh
薇薇安 5f256daf27 feat(recommendations): 添加推荐服务管理API与前端控制功能
在后端API中新增推荐服务的状态检查、重启、停止和启动功能,确保能够有效管理推荐服务进程。同时,更新前端组件以支持推荐服务状态的显示与控制,提升用户体验。此改动为推荐服务的管理提供了更直观的操作界面与实时状态反馈。
2026-02-23 18:02:53 +08:00

36 lines
1.0 KiB
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
# 启动推荐服务recommendations_main
# 参考 backend/start.sh使用相同 venv 与项目根目录
cd "$(dirname "$0")"
PROJECT_ROOT="$(cd .. && pwd)"
# 激活虚拟环境(与 backend/start.sh 一致)
if [ -d ".venv" ]; then
source .venv/bin/activate
elif [ -d "../.venv" ]; then
source ../.venv/bin/activate
else
echo "错误: 找不到虚拟环境(.venv 或 ../.venv"
exit 1
fi
# 设置环境变量(与 backend/start.sh 类似)
export PYTHONPATH="${PROJECT_ROOT}"
export DB_HOST=${DB_HOST:-localhost}
export DB_PORT=${DB_PORT:-3306}
export DB_USER=${DB_USER:-autosys}
export DB_PASSWORD=${DB_PASSWORD:-}
export DB_NAME=${DB_NAME:-auto_trade_sys}
export LOG_LEVEL=${LOG_LEVEL:-INFO}
# 创建日志目录
mkdir -p "${PROJECT_ROOT}/logs"
# 启动推荐服务(后台运行)
cd "${PROJECT_ROOT}"
nohup python -m trading_system.recommendations_main > logs/recommendations.log 2>&1 &
PID=$!
echo "推荐服务已启动PID: $PID"
echo "日志: tail -f ${PROJECT_ROOT}/logs/recommendations.log"