-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_loopback.sh
More file actions
executable file
·39 lines (32 loc) · 1.08 KB
/
Copy pathrun_loopback.sh
File metadata and controls
executable file
·39 lines (32 loc) · 1.08 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
#!/bin/bash
# Terminate existing background servers or anyone else on ports 8000 and 5173
echo "Cleaning up any processes on ports 8000 and 5173..."
PORT_8000_PID=$(lsof -t -i:8000 2>/dev/null)
if [ ! -z "$PORT_8000_PID" ]; then
echo "Killing process on port 8000 (PID: $PORT_8000_PID)..."
kill -9 $PORT_8000_PID 2>/dev/null || true
fi
PORT_5173_PID=$(lsof -t -i:5173 2>/dev/null)
if [ ! -z "$PORT_5173_PID" ]; then
echo "Killing process on port 5173 (PID: $PORT_5173_PID)..."
kill -9 $PORT_5173_PID 2>/dev/null || true
fi
# Start backend in the background
echo "Starting Loopback FastAPI Backend on http://localhost:8000..."
python3 -m uvicorn backend.main:app --port 8000 --reload &
BACKEND_PID=$!
# Start frontend
echo "Starting Loopback Vite Frontend on http://localhost:5173..."
cd frontend
npm run dev &
FRONTEND_PID=$!
# Setup cleanup traps
cleanup() {
echo -e "\nGracefully shutting down Loopback servers..."
kill $BACKEND_PID 2>/dev/null || true
kill $FRONTEND_PID 2>/dev/null || true
exit 0
}
trap cleanup SIGINT SIGTERM
# Wait for both processes
wait