nex_buddy/scripts/start.sh

26 lines
822 B
Bash
Raw Normal View History

2026-11-13 06:38:19 +00:00
#!/usr/bin/env bash
# 生产启动:scripts/start.sh [端口]
# 由 systemd/supervisor 调用;不建 venv、不跑迁移,部署阶段由 scripts/deploy.sh 完成。
set -euo pipefail
cd "$(dirname "$0")/.."
PORT="${1:-}"
if [ -z "$PORT" ]; then
PORT="$(grep -E '^BACKEND_PORT=' .env 2>/dev/null | tail -1 | cut -d= -f2 | tr -d '[:space:]' || true)"
2026-11-13 08:51:05 +00:00
PORT="${PORT:-8000}"
2026-11-13 06:38:19 +00:00
fi
if [ ! -x .venv/bin/python ]; then
echo "!! 未找到 .venv/bin/python,请先执行 scripts/deploy.sh" >&2
exit 1
fi
WORKERS="${WEB_CONCURRENCY:-2}"
echo ">> 启动 http://0.0.0.0:${PORT}(workers=${WORKERS})"
cd server && exec ../.venv/bin/python -m uvicorn app.main:app \
--host "${HOST:-0.0.0.0}" \
--port "$PORT" \
--workers "$WORKERS" \
--proxy-headers \
--forwarded-allow-ips "${FORWARDED_ALLOW_IPS:-127.0.0.1}"