26 lines
822 B
Bash
Executable File
26 lines
822 B
Bash
Executable File
#!/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:-8100}"
|
||
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}"
|