deep-risk/entrypoint.sh
2025-12-14 20:08:27 +08:00

57 lines
1.2 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
set -e
echo "=========================================="
echo "启动 DeepRisk 税务风控系统"
echo "=========================================="
# 设置环境变量
export PYTHONPATH=/app:$PYTHONPATH
export PYTHONUNBUFFERED=1
# 进入应用目录
cd /app
# 配置日志
if [ -f "/app/app/utils/logger.py" ]; then
/usr/local/bin/python3 -c "from app.utils.logger import setup_logger; setup_logger()" || true
fi
echo "正在启动 FastAPI 后端服务..."
# 启动 FastAPI 服务(后台运行)
/usr/local/bin/python3 -m uvicorn app.main:app \
--host 0.0.0.0 \
--port 8000 \
--log-level info \
> /app/logs/backend.log 2>&1 &
BACKEND_PID=$!
echo "FastAPI 后端已启动 (PID: $BACKEND_PID)"
# 等待后端服务启动
echo "等待后端服务准备就绪..."
for i in {1..30}; do
if curl -s http://127.0.0.1:8000/health > /dev/null 2>&1; then
echo "✓ 后端服务已准备就绪"
break
fi
if [ $i -eq 30 ]; then
echo "⚠ 后端服务启动超时,但将继续启动..."
fi
sleep 1
done
echo ""
echo "启动 nginx..."
# 确保日志目录存在
mkdir -p /var/log/nginx
mkdir -p /app/logs
# 启动 nginx前台运行
exec nginx -g "daemon off;"