nex_buddy/scripts/start.sh

26 lines
822 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/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)"
PORT="${PORT:-8000}"
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}"