-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·57 lines (47 loc) · 1.26 KB
/
run.sh
File metadata and controls
executable file
·57 lines (47 loc) · 1.26 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
#!/bin/bash
clear
# Function to kill processes running on specified ports
kill_ports() {
local ports=("$@")
for port in "${ports[@]}"; do
echo "Checking for processes running on port $port..."
pid=$(lsof -t -i:$port)
if [ -n "$pid" ]; then
echo "Killing process $pid on port $port..."
kill -9 $pid
else
echo "No process running on port $port."
fi
done
}
# Kill processes running on ports 3000 and 3001
kill_ports 3000 3001
# Start the Node.js server
if [ -d "server" ]; then
echo "Starting Node.js server..."
cd server || exit
npm start &
cd ..
else
echo "Server directory not found! Skipping server start."
fi
echo "Waiting for servers to start..."
sleep 5
# Start the React app
if [ -d "client" ]; then
echo "Starting React app..."
cd client || exit
npm start &
cd ..
else
echo "Client directory not found! Skipping React app start."
fi
echo "All components are running!"
echo "Access the application at http://localhost:3000"
# Wait for the user to stop the servers
read -p "Press [ENTER] to stop the servers..."
# Stop the servers
echo "Stopping servers..."
pkill -f "node server/server.js"
pkill -f "react-scripts start"
echo "All components stopped."