#!/usr/bin/env bash
set -e

BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
export WEIXIN_HEADLESS_MODE=headful
export WEIXIN_DEBUG_ARTIFACTS=false
export WEIXIN_RECORD_VIDEO=false
export DOUYIN_DEBUG_ARTIFACTS=false
export DOUYIN_RECORD_VIDEO=false
PORT=${PORT:-8006}

cd "$BASE_DIR/backend"

# 加载 .env 文件（让 os.getenv 也能读到）
if [ -f .env ]; then
  set -a
  source .env
  set +a
fi

exec xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24" \
  ./venv/bin/uvicorn app.main:app --host 0.0.0.0 --port "$PORT"
