Files
AIRegulation-DocAnalysis/start_api.sh
2026-04-28 11:29:33 +08:00

47 lines
1.0 KiB
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
# start_api.sh - 启动API服务支持虚拟环境
set -e
VENV_DIR=".venv"
# 创建日志目录
mkdir -p logs
echo "========================================"
echo "启动 AI+合规智能中枢 API服务"
echo "========================================"
echo ""
# 检查虚拟环境
if [ ! -d "$VENV_DIR" ]; then
echo "错误: 虚拟环境不存在,请先运行 ./quick_start.sh"
exit 1
fi
# 激活虚拟环境
source $VENV_DIR/bin/activate
echo "已激活虚拟环境: $VENV_DIR"
echo ""
# 检查.env文件
if [ ! -f ".env" ]; then
echo "警告: .env文件不存在使用默认配置"
fi
# 启动参数
HOST=${API_HOST:-0.0.0.0}
PORT=${API_PORT:-8000}
echo "API地址: http://$HOST:$PORT"
echo "API文档: http://$HOST:$PORT/docs"
echo "健康检查: http://$HOST:$PORT/health"
echo ""
echo "前端测试页面:"
echo " 直接打开: frontend/index.html"
echo " 或启动服务: ./start_frontend.sh"
echo ""
echo "正在启动..."
echo ""
python -m uvicorn src.api.main:app --host $HOST --port $PORT --reload