Files
10AM/run.sh
2025-09-09 17:29:49 +02:00

50 lines
1.2 KiB
Bash
Executable File
Raw Permalink 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
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
# Helpful banner
echo "10AM dev runner"
echo "Frontend will be on http://localhost:5173"
echo "Backend API on http://127.0.0.1:8000"
echo
# Ensure deps
command -v python3 >/dev/null || { echo "python3 not found"; exit 1; }
command -v npm >/dev/null || { echo "npm not found"; exit 1; }
# Start backend (serves /ten-am and /state). It will also start the collector (see patch below).
(
cd "$ROOT/server"
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export TENAM_DATA="$ROOT/server/capitals_tz.json"
python3 tenam_full_server.py --host 127.0.0.1 --port 8000
) &
BACKEND_PID=$!
# Start frontend (Vite dev) with proxy to backend (already configured in vite.config.ts)
(
cd "$ROOT/frontend"
if [ ! -d node_modules ]; then
echo "Installing frontend deps…"
npm install
fi
npm run dev -- --host --port 5173
) &
FRONTEND_PID=$!
# Cleanup on exit
cleanup() {
echo
echo "Shutting down…"
kill "$BACKEND_PID" "$FRONTEND_PID" 2>/dev/null || true
wait 2>/dev/null || true
}
trap cleanup INT TERM
# Info
echo "Open: http://localhost:5173"
echo "Press Ctrl+C to stop."
wait