-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·61 lines (48 loc) · 1.65 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·61 lines (48 loc) · 1.65 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
#!/usr/bin/env bash
# Starts the Vectis backend (FastAPI/uvicorn) and frontend (Vite) dev servers.
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKEND_DIR="$ROOT_DIR/backend"
FRONTEND_DIR="$ROOT_DIR/frontend"
resolve_python_bin() {
if [[ -n "${VIRTUAL_ENV:-}" ]] && [[ -x "$VIRTUAL_ENV/bin/python" ]]; then
printf '%s\n' "$VIRTUAL_ENV/bin/python"
return 0
fi
if [[ -x "$ROOT_DIR/.venv/bin/python" ]]; then
printf '%s\n' "$ROOT_DIR/.venv/bin/python"
return 0
fi
if [[ -x "$BACKEND_DIR/.venv/bin/python" ]]; then
printf '%s\n' "$BACKEND_DIR/.venv/bin/python"
return 0
fi
command -v python3
}
PYTHON_BIN="$(resolve_python_bin)"
if [[ -z "$PYTHON_BIN" ]]; then
echo "Could not find a Python interpreter. Activate a virtualenv or create one at .venv/."
exit 1
fi
if ! "$PYTHON_BIN" -c 'import uvicorn' >/dev/null 2>&1; then
echo "Missing backend dependency: uvicorn is not installed for $PYTHON_BIN"
echo "Run: $PYTHON_BIN -m pip install -r $BACKEND_DIR/requirements.txt"
exit 1
fi
if [[ ! -d "$FRONTEND_DIR/node_modules" ]]; then
echo "Frontend dependencies are missing in $FRONTEND_DIR/node_modules"
echo "Run: cd $FRONTEND_DIR && npm install"
exit 1
fi
cleanup() {
echo "Stopping servers..."
kill "${BACKEND_PID:-}" "${FRONTEND_PID:-}" 2>/dev/null || true
}
trap cleanup EXIT INT TERM
echo "Starting backend (FastAPI) on http://127.0.0.1:8000 ..."
(cd "$BACKEND_DIR" && "$PYTHON_BIN" -m uvicorn main:app --reload --port 8000) &
BACKEND_PID=$!
echo "Starting frontend (Vite) on http://127.0.0.1:5173 ..."
(cd "$FRONTEND_DIR" && npm run dev) &
FRONTEND_PID=$!
wait "$BACKEND_PID" "$FRONTEND_PID"