-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·87 lines (67 loc) · 2.09 KB
/
dev.sh
File metadata and controls
executable file
·87 lines (67 loc) · 2.09 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
# dev.sh — Start Artifactor backend + frontend for local development.
# Usage: ./dev.sh
# Stop: Ctrl-C (kills both processes)
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
BACKEND_PORT="${BACKEND_PORT:-8000}"
FRONTEND_PORT="${FRONTEND_PORT:-3000}"
PIDS=()
cleanup() {
echo ""
echo "Shutting down..."
for pid in "${PIDS[@]}"; do
kill "$pid" 2>/dev/null || true
done
for pid in "${PIDS[@]}"; do
wait "$pid" 2>/dev/null || true
done
echo "Done."
}
trap cleanup EXIT INT TERM
# --- Preflight checks ---
if ! command -v uv &>/dev/null; then
echo "ERROR: uv is not installed. Install it: https://docs.astral.sh/uv/getting-started/"
exit 1
fi
if ! command -v pnpm &>/dev/null; then
echo "ERROR: pnpm is not installed. Install it: npm i -g pnpm"
exit 1
fi
# --- Install dependencies (idempotent, fast if already installed) ---
echo "==> Installing Python dependencies..."
uv sync --extra dev --quiet
echo "==> Installing frontend dependencies..."
(cd "$ROOT/frontend" && pnpm install --silent)
# --- Create data directories ---
mkdir -p "$ROOT/data" "$ROOT/logs"
# --- Free ports if occupied by stale processes ---
for port in "$BACKEND_PORT" "$FRONTEND_PORT"; do
stale_pids=$(lsof -ti :"$port" 2>/dev/null || true)
if [[ -n "$stale_pids" ]]; then
echo "==> Killing stale process on port $port"
echo "$stale_pids" | xargs kill 2>/dev/null || true
sleep 0.5
fi
done
# --- Start backend ---
echo "==> Starting backend on http://localhost:$BACKEND_PORT"
uv run uvicorn artifactor.main:app \
--reload \
--host 0.0.0.0 \
--port "$BACKEND_PORT" &
PIDS+=($!)
# --- Start frontend ---
echo "==> Starting frontend on http://localhost:$FRONTEND_PORT"
BACKEND_URL="http://localhost:$BACKEND_PORT" \
pnpm --dir "$ROOT/frontend" dev --port "$FRONTEND_PORT" &
PIDS+=($!)
echo ""
echo "========================================="
echo " Backend: http://localhost:$BACKEND_PORT"
echo " Frontend: http://localhost:$FRONTEND_PORT"
echo " Press Ctrl-C to stop both."
echo "========================================="
echo ""
# Wait forever until Ctrl-C
wait