stock-ai-agent/start.sh
2026-02-03 10:08:15 +08:00

79 lines
1.9 KiB
Bash
Executable File
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
# A股AI分析Agent系统 - 快速启动脚本
echo "================================"
echo "A股AI分析Agent系统 - 启动脚本"
echo "================================"
echo ""
# 检查Python版本
echo "检查Python版本..."
python_version=$(python3 --version 2>&1 | awk '{print $2}')
echo "Python版本: $python_version"
# 检查是否在虚拟环境中
if [[ "$VIRTUAL_ENV" == "" ]]; then
echo ""
echo "警告: 未检测到虚拟环境"
echo "建议创建虚拟环境:"
echo " python3 -m venv venv"
echo " source venv/bin/activate # macOS/Linux"
echo " venv\\Scripts\\activate # Windows"
echo ""
read -p "是否继续?(y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# 检查.env文件
if [ ! -f ".env" ]; then
echo ""
echo "错误: 未找到.env文件"
echo "请复制.env.example为.env并配置"
echo " cp .env.example .env"
echo " 然后编辑.env文件填写必要的配置"
exit 1
fi
# 检查依赖
echo ""
echo "检查依赖..."
cd backend
if [ ! -d "venv" ] && [[ "$VIRTUAL_ENV" == "" ]]; then
echo "安装依赖..."
pip3 install -r requirements.txt
fi
# 检查Redis可选
echo ""
echo "检查Redis..."
if command -v redis-cli &> /dev/null; then
if redis-cli ping &> /dev/null; then
echo "✓ Redis运行正常"
else
echo "⚠ Redis未运行可选系统会自动降级"
echo " 启动Redis: redis-server"
fi
else
echo "⚠ Redis未安装可选系统会自动降级"
fi
# 启动应用
echo ""
echo "================================"
echo "启动应用..."
echo "================================"
echo ""
echo "访问地址:"
echo " 前端界面: http://localhost:8000"
echo " API文档: http://localhost:8000/docs"
echo ""
echo "按 Ctrl+C 停止服务"
echo ""
python3 -m app.main