it-architecture/dev.sh

19 lines
599 B
Bash
Executable File
Raw Permalink 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
# 开发模式:后端 8787(热重载)+ 前端 5273(HMR,已代理 /api 到后端)。
set -euo pipefail
cd "$(dirname "$0")"
export DB_PATH="${DB_PATH:-$PWD/backend/panorama.db}"
export RELOAD=1
cleanup() { kill 0 2>/dev/null || true; }
trap cleanup EXIT INT TERM
echo "==> 后端 http://localhost:8787 (API 文档 /docs)"
(cd backend && python3 -m uvicorn app.main:app --host 0.0.0.0 --port 8787 --reload) &
[ -d frontend/node_modules ] || (cd frontend && npm install --no-audit --no-fund)
echo "==> 前端 http://localhost:5273"
(cd frontend && npm run dev)