Files
FishServer/fish_api/start_fresh.sh
zaiun xu 5e1b2117c1 feat(fish_api): SQLite 快照投递、日志与 watch 空闲告警
- 新增 SQLite:measure/health 快照、delivery_cursor 单消费者 pop;clear/start_fresh 可清空库
- biomass GET 仅返回约定 data 字段,X-Fish-Biomass-New 表示是否有新快照;poller 读响应头
- loguru 桥接 uvicorn,子进程 stdout 流式输出;format_json_pretty 与算法摘要日志
- measure/action watch 无新任务时限流 WARNING;watch_idle 共用逻辑
- 依赖 loguru;新增 db、logging_config、subprocess_run、watch_idle、启动脚本

FishMeasure: 更新 fish_video_weight_evaluation 与 predict_weigth_from_svo2;移除未用 refbox/segmentation 脚本
Made-with: Cursor
2026-04-09 11:54:30 +08:00

70 lines
2.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 一键启动 Fish API删除整个 SQLite 库文件(含 -wal/-shm并删除旧版 watch JSON 状态文件,再启动服务。
#
# bash fish_api/start_fresh.sh
# PORT=8001 HOST=0.0.0.0 bash fish_api/start_fresh.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[@]}" - <<'PY'
from pathlib import Path
from app.db import remove_sqlite_database_files
from app.settings import get_settings
s = get_settings()
def _rm(path: Path | None) -> None:
if path is None:
return
try:
if path.is_file():
path.unlink()
print(f"[start-fresh] removed legacy JSON {path}", flush=True)
except OSError as e:
print(f"[start-fresh] skip {path}: {e}", flush=True)
remove_sqlite_database_files(s)
print(f"[start-fresh] removed SQLite database at {s.sqlite_path} (and -wal/-shm if present).", flush=True)
# 旧版 JSON 若仍存在,启动时会被 load_watch_processed 合并进 SQLite必须一并删除
if s.measure_watch_use_state_file:
if s.measure_watch_state_file is not None:
_rm(s.measure_watch_state_file)
elif s.measure_watch_dir is not None:
_rm(s.measure_watch_dir / ".fishmeasure_watch_processed.json")
if s.action_watch_use_state_file:
if s.action_watch_state_file is not None:
_rm(s.action_watch_state_file)
elif s.action_watch_dir is not None:
_rm(s.action_watch_dir / ".fishaction_watch_processed.json")
print("[start-fresh] done.", flush=True)
PY
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