-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·56 lines (41 loc) · 1.33 KB
/
start.sh
File metadata and controls
executable file
·56 lines (41 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
#!/usr/bin/env bash
set -e
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Backend
echo ">>> Setting up backend..."
cd "$REPO_ROOT/backend"
if [ ! -d ".venv" ]; then
python3 -m venv .venv
fi
source .venv/bin/activate
pip install -r requirements.txt --quiet
python manage.py migrate --run-syncdb
# Load players only if the table is empty
PLAYER_COUNT=$(python manage.py shell -c "from backend_api.models import Player; print(Player.objects.count())" 2>/dev/null || echo "0")
if [ "$PLAYER_COUNT" = "0" ]; then
echo ">>> Loading player data..."
python manage.py load_players
else
echo ">>> Players already loaded, skipping."
fi
# Create default moderator if it doesn't exist
python manage.py create_moderator --username admin --password admin 2>/dev/null || true
echo ">>> Starting Django on http://localhost:8000 ..."
python manage.py runserver &
BACKEND_PID=$!
# Frontend
echo ">>> Setting up frontend..."
cd "$REPO_ROOT/frontend"
npm install --silent
echo ">>> Starting Vite on http://localhost:5173 ..."
npm start &
FRONTEND_PID=$!
# Cleanup on exit
trap "echo '>>> Shutting down...'; kill $BACKEND_PID $FRONTEND_PID 2>/dev/null" EXIT INT TERM
echo ""
echo "App running:"
echo " Frontend → http://localhost:5173"
echo " Backend → http://localhost:8000"
echo ""
echo "Press Ctrl+C to stop."
wait $BACKEND_PID $FRONTEND_PID