-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartwsl.sh
61 lines (47 loc) · 1.5 KB
/
startwsl.sh
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
#!/bin/bash
init_backend() {
if [ -d ./venv ]; then
echo "Virtual environment already exists, skipping."
else
echo "Creating virtual environment."
python -m pip install virtualenv
python3 -m venv venv
venv/bin/pip install -r backend/requirements.txt
# Apply migrations
venv/bin/python backend/manage.py migrate
# Create superuser
export DJANGO_SUPERUSER_USERNAME=admin
export DJANGO_SUPERUSER_PASSWORD=1234
export [email protected]
venv/bin/python backend/manage.py createsuperuser --no-input --displayName "Admin" --githubUrl "https://github.com/uofa-cmput404"
fi
# Apply migrations again (just in case)
venv/bin/python backend/manage.py migrate
}
init_frontend() {
echo "Installing frontend dependencies."
cd frontend || exit
npm install
cd ..
}
# cleanup() {
# echo "Stopping backend and frontend..."
# kill -9 $(ps -A | grep python | awk '{print $1}')
# kill -9 $(ps -A | grep npm | awk '{print $1}')
# kill -9 $(ps -A | grep vite | awk '{print $1}')
# }
start_parallel() {
# trap cleanup SIGINT
echo "Starting backend + frontend in parallel."
venv/bin/python backend/manage.py runserver 0.0.0.0:8000 &
BACKEND_PID=$!
cd frontend || exit
npm run dev &
FRONTEND_PID=$!
cd ..
# Manual loop to periodically check if the processes have terminated
}
# Call the functions
init_backend
init_frontend
start_parallel