-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·57 lines (48 loc) · 2.2 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·57 lines (48 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
set -e
ROOT="$(cd "$(dirname "$0")" && pwd)"
# ── check venv ──────────────────────────────────────────────────────────────
if [ ! -f "$ROOT/venv/bin/activate" ]; then
echo "venv not found. setting it up..."
python3 -m venv "$ROOT/venv"
source "$ROOT/venv/bin/activate"
pip install -q -r "$ROOT/requirements.txt"
else
source "$ROOT/venv/bin/activate"
fi
# ── check .env ───────────────────────────────────────────────────────────────
if [ -f "$ROOT/.env" ]; then
ENV_FILE="$ROOT/.env"
elif [ -f "$ROOT/backend/.env" ]; then
ENV_FILE="$ROOT/backend/.env"
else
echo "⚠ no .env file found (checked .env and backend/.env) — fill one in before running."
exit 1
fi
# ── start backend ────────────────────────────────────────────────────────────
echo "starting backend on http://localhost:5000 ..."
cd "$ROOT/backend"
python app.py &
BACKEND_PID=$!
# ── start frontend ───────────────────────────────────────────────────────────
echo "starting frontend on http://localhost:3000 ..."
cd "$ROOT/frontend"
python3 -m http.server 3000 --bind 127.0.0.1 > /dev/null 2>&1 &
FRONTEND_PID=$!
# ── open browser (after a short pause for servers to start) ─────────────────
sleep 1
open "http://localhost:3000" 2>/dev/null || true
echo ""
echo "margin is running → http://localhost:3000"
echo "press Ctrl+C to stop."
echo ""
# ── wait and clean up on exit ────────────────────────────────────────────────
cleanup() {
echo ""
echo "shutting down..."
kill "$BACKEND_PID" 2>/dev/null || true
kill "$FRONTEND_PID" 2>/dev/null || true
exit 0
}
trap cleanup INT TERM
wait