-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_servers.sh
executable file
·40 lines (32 loc) · 1000 Bytes
/
start_servers.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
#!/bin/bash
# Activate the Conda environment
echo "Activating Conda environment..."
source /opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh
conda activate PhotoRealisticAI
conda info | grep 'active environment'
# Function to clean up processes on exit
cleanup() {
echo "Cleaning up..."
# Terminate both processes
kill -SIGTERM $backend_pid $ng_serve_pid
exit 0
}
# Trap interrupt signal (Ctrl+C) to call the cleanup function
trap cleanup INT
# Start the backend API
echo "Starting backend API..."
python backend/main.py &
# Capture the process ID (PID) of the backend API command
backend_pid=$!
sleep 10
# Start the frontend server in the background
echo "Starting frontend server..."
cd frontend/photorealistic-ai-frontend
ng serve &
# Capture the process ID (PID) of the ng serve command
ng_serve_pid=$!
# Wait for the backend to start (you may need to adjust the sleep duration)
sleep 10
# Wait for both processes to finish
wait $backend_pid
wait $ng_serve_pid