Files
2026-07-17 09:24:47 +08:00

40 lines
1.2 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.
#!/usr/bin/env bash
# 宝塔 Python 项目 - 启动命令
# 面板「启动命令」必须填这一行(不要用 .venv/bin/uvicorn:
# bash /www/wwwroot/douyin/backend/baota_start.sh
set -euo pipefail
BACKEND="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$BACKEND/.." && pwd)"
# shellcheck source=lib/resolve_python.sh
source "$BACKEND/lib/resolve_python.sh"
cd "$BACKEND"
PY="$(resolve_python "$BACKEND" "$ROOT")"
ensure_uvicorn "$PY" "$BACKEND"
export PLAYWRIGHT_BROWSERS_PATH="${PLAYWRIGHT_BROWSERS_PATH:-$ROOT/playwright-browsers}"
export KEFU_SERVE_WEB="${KEFU_SERVE_WEB:-true}"
export KEFU_STATIC_DIR="${KEFU_STATIC_DIR:-$ROOT/frontend/dist}"
# 启动前检查 Chromium(缺失时给出明确提示)
if ! find "$PLAYWRIGHT_BROWSERS_PATH" -name chrome -type f 2>/dev/null | grep -q .; then
echo "[警告] 未找到 Chromium,请执行: bash $BACKEND/baota_playwright.sh" >&2
fi
if [ -f "$ROOT/.env" ]; then
set -a
# shellcheck disable=SC1090
source "$ROOT/.env"
set +a
fi
HOST="${KEFU_HOST:-0.0.0.0}"
PORT="${KEFU_PORT:-8000}"
echo "[baota] Python: $PY"
echo "[baota] Listen: http://${HOST}:${PORT}"
exec "$PY" -m uvicorn main:app --host "$HOST" --port "$PORT"