-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
71 lines (61 loc) · 1.33 KB
/
Copy pathrun.sh
File metadata and controls
71 lines (61 loc) · 1.33 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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PYTHON_BIN=""
BACKEND_PID=""
WEB_PID=""
if [[ -x "$ROOT_DIR/.venv/Scripts/python.exe" ]]; then
PYTHON_BIN="$ROOT_DIR/.venv/Scripts/python.exe"
elif [[ -x "$ROOT_DIR/.venv/bin/python" ]]; then
PYTHON_BIN="$ROOT_DIR/.venv/bin/python"
else
PYTHON_BIN="python"
fi
cleanup() {
if [[ -n "$BACKEND_PID" ]] && kill -0 "$BACKEND_PID" 2>/dev/null; then
kill "$BACKEND_PID" 2>/dev/null || true
fi
if [[ -n "$WEB_PID" ]] && kill -0 "$WEB_PID" 2>/dev/null; then
kill "$WEB_PID" 2>/dev/null || true
fi
}
trap cleanup EXIT INT TERM
start_backend() {
cd "$ROOT_DIR/backend"
"$PYTHON_BIN" main.py &
BACKEND_PID=$!
echo "Backend started on http://127.0.0.1:8000"
}
start_web() {
cd "$ROOT_DIR/web"
"$PYTHON_BIN" -m http.server 8080 &
WEB_PID=$!
echo "Web server started on http://127.0.0.1:8080"
}
start_mobile() {
cd "$ROOT_DIR/mobile"
npx expo start -c
}
case "${1:-all}" in
all)
start_backend
start_web
start_mobile
;;
backend)
cd "$ROOT_DIR/backend"
"$PYTHON_BIN" main.py
;;
web)
cd "$ROOT_DIR/web"
"$PYTHON_BIN" -m http.server 8080
;;
mobile)
cd "$ROOT_DIR/mobile"
npx expo start -c
;;
*)
echo "Usage: ./run.sh [all|backend|web|mobile]"
exit 1
;;
esac