-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_app.sh
More file actions
executable file
·56 lines (46 loc) · 1.15 KB
/
start_app.sh
File metadata and controls
executable file
·56 lines (46 loc) · 1.15 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
#!/bin/bash
cd "$(dirname "$0")"
# Start Backend
echo "Starting Backend..."
cd backend
# Check if venv exists, if not, create it
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
else
source venv/bin/activate
fi
# Start FastAPI
# Use lsof to check if port 4445 is free, if not kill it
if lsof -t -i :4445 > /dev/null; then
echo "Port 4445 is in use, killing process..."
lsof -t -i :4445 | xargs kill -9
fi
uvicorn app.main:app --reload --port 4445 &
BACKEND_PID=$!
cd ..
# Start Frontend
echo "Starting Frontend..."
cd frontend
# Check if node_modules exists
if [ ! -d "node_modules" ]; then
echo "Installing frontend dependencies..."
npm install
fi
npm run dev &
FRONTEND_PID=$!
cd ..
# Set trap to kill processes on exit
trap "kill $BACKEND_PID $FRONTEND_PID" EXIT
# Wait for servers to start
echo "Waiting for services to start..."
sleep 5
# Open Browser
echo "Opening Browser..."
open http://localhost:4444
echo "Application is running."
echo "Press CTRL+C to stop the servers..."
# Wait for processes
wait $BACKEND_PID $FRONTEND_PID