33 lines
828 B
Bash
33 lines
828 B
Bash
#!/usr/bin/env bash
|
||
# 一键启动 Fish API:先清空 SQLite、watch 状态与运行时目录(与 start_fresh.sh 相同),再启动 uvicorn。
|
||
#
|
||
# bash fish_api/start.sh
|
||
# PORT=8001 HOST=0.0.0.0 bash fish_api/start.sh
|
||
#
|
||
# 首次使用请先:cd fish_api && uv sync
|
||
#
|
||
set -euo pipefail
|
||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
cd "$DIR"
|
||
|
||
export PUBLIC_BASE_URL="${PUBLIC_BASE_URL:-http://127.0.0.1:8000}"
|
||
unset PYTHON_FISH_MEASURE PYTHON_FISH_ACTION 2>/dev/null || true
|
||
|
||
if command -v uv >/dev/null 2>&1; then
|
||
PY=(uv run python)
|
||
else
|
||
PY=(python3)
|
||
fi
|
||
|
||
"${PY[@]}" -m app.prestart_fresh
|
||
|
||
PORT="${PORT:-8000}"
|
||
HOST="${HOST:-0.0.0.0}"
|
||
|
||
if command -v uv >/dev/null 2>&1; then
|
||
exec uv run uvicorn app.main:app --host "$HOST" --port "$PORT"
|
||
else
|
||
exec uvicorn app.main:app --host "$HOST" --port "$PORT"
|
||
fi
|