-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_app_dev.sh
executable file
·56 lines (45 loc) · 1.24 KB
/
start_app_dev.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
#!/bin/bash
#
SERVER_ADDR=127.0.0.1
SERVER_PORT=50010
CLIENT_PORT=50011
kill_process_on_port() {
PORT=$1
PID=$(lsof -ti tcp:$PORT) # Get the process ID using the port
if [ -n "$PID" ]; then
echo "Process running on port $PORT with PID $PID. Killing process..."
kill -9 $PID
echo "Process on port $PORT has been killed."
else
echo "No process running on port $PORT."
fi
}
# Check and kill any process running on SERVER_PORT
kill_process_on_port $SERVER_PORT
# Check and kill any process running on CLIENT_PORT
kill_process_on_port $CLIENT_PORT
. ~/.bashrc
source /home/$USER/work/dials/conda_base/etc/profile.d/conda.sh
conda activate /home/$USER/work/dials/conda_base
# Navigate to the directory containing your server script
cd /home/$USER/work/dials_browser_gui/server
# Start the Python server in the background
python server.py $SERVER_ADDR $SERVER_PORT &
sleep 2
SERVER_PID=$!
# Navigate to the directory containing your React client
cd /home/$USER/work/dials_browser_gui/client
# Start the React client
npm run dev &
CLIENT_PID=$!
sleep 2
npx electron .
cleanup() {
echo "Closing client..."
kill $CLIENT_PID
echo "Closing server..."
kill $SERVER_PID
}
trap cleanup EXIT
# Wait for the Python server process to finish
wait $SERVER_PID