Files
012-kaopeilian/backend/start.sh
yuliang_guo e110067840
All checks were successful
continuous-integration/drone/push Build is passing
feat: 添加统一启动脚本,支持通过环境变量配置workers数量
- 新增 start.sh 启动脚本,根据 WORKERS/RELOAD 环境变量自动配置
- 修改 Dockerfile 使用启动脚本,默认 WORKERS=4
- 更新 docker-compose.prod-multi.yml,所有租户使用环境变量配置
- 生产环境默认4个workers,提升并发处理能力

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-03 14:25:34 +08:00

39 lines
1.0 KiB
Bash
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
# 统一启动脚本 - 根据环境变量自动配置
# 默认配置
HOST=${HOST:-0.0.0.0}
PORT=${PORT:-8000}
WORKERS=${WORKERS:-1}
RELOAD=${RELOAD:-false}
TIMEOUT_KEEP_ALIVE=${TIMEOUT_KEEP_ALIVE:-600}
echo "=============================================="
echo " KaoPeiLian Backend Starting..."
echo "=============================================="
echo " HOST: $HOST"
echo " PORT: $PORT"
echo " WORKERS: $WORKERS"
echo " RELOAD: $RELOAD"
echo " TIMEOUT_KEEP_ALIVE: $TIMEOUT_KEEP_ALIVE"
echo "=============================================="
# 构建启动命令
CMD="uvicorn app.main:app --host $HOST --port $PORT --timeout-keep-alive $TIMEOUT_KEEP_ALIVE"
if [ "$RELOAD" = "true" ]; then
# 开发模式启用热重载不支持多workers
CMD="$CMD --reload --reload-dir /app/app"
echo "Mode: Development (hot reload enabled)"
else
# 生产模式多workers
CMD="$CMD --workers $WORKERS"
echo "Mode: Production ($WORKERS workers)"
fi
echo ""
echo "Executing: $CMD"
echo ""
exec $CMD