Files
dxin 82a4aa0e14 +1
2025-10-16 11:52:59 +08:00

76 lines
1.8 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.

# chmod +x start.sh
#-----------------------------------------
#!/usr/bin/env bash
set -e
# 打印启动环境
echo "[*] Starting app with APP_ENV=${APP_ENV}"
# 日志路径(宿主机会挂载)
LOG_DIR="/app/logs"
mkdir -p "$LOG_DIR"
# 动态生成日志文件名
LOGFILE="${LOG_DIR}/lessie_sourcing_agents_$(date +'%Y%m%d_%H%M%S').log"
LATEST_LOG="${LOG_DIR}/lessie_sourcing_agents_latest.log"
# 启动命令
echo "[*] Launching Gunicorn..."
nohup env APP_ENV=${APP_ENV} \
gunicorn -w 4 -k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:7001 --timeout 300 dialogue.app:app \
--max-requests 500 --max-requests-jitter 50 \
> "$LOGFILE" 2>&1 &
# 建立软链方便查看最新日志
ln -sf "$LOGFILE" "$LATEST_LOG"
echo "[*] App started. Logs: $LATEST_LOG"
# 前台挂起(防止容器退出)
tail -F "$LOGFILE"
#-----------------------------------------
#!/bin/bash
#脚本出错立即退出,防止容器假活
set -e
# 进入项目目录
cd /app
# 日志目录
LOG_DIR="/app/logs"
mkdir -p "$LOG_DIR"
# 日志文件(同时软链一个 latest.log 方便定位)
LOG_FILE="${LOG_DIR}/lessie_sourcing_agents_$(date +'%Y%m%d_%H%M%S').log"
ln -sf "$LOG_FILE" "${LOG_DIR}/lessie_sourcing_agents_latest.log"
# 环境变量(默认 prod可通过 docker run -e APP_ENV=s1 覆盖)
APP_ENV="${APP_ENV:-prod}"
echo "[INFO] Starting app in environment: ${APP_ENV}"
# Python 环境检查
echo "[INFO] Python version:"
python3 --version
# 启动 Gunicorn
# 输出到 stdout 的同时 tee 一份到日志文件
echo "[INFO] Launching Gunicorn..."
exec gunicorn -w ${cfg_gunicornWorkers:-4} \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:${cfg_port:-7001} \
--timeout 300 \
--max-requests 500 \
--max-requests-jitter 50 \
--access-logfile - \
--error-logfile - \
dialogue.app:app \
2>&1 | tee -a "$LOG_FILE"