-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·47 lines (36 loc) · 1.04 KB
/
start.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
#!/bin/bash
echo "Starting servers..."
source venv/bin/activate
# Function to handle cleanup
cleanup() {
echo "Stopping servers..."
kill $WEBPACK_PID $PLAYGROUND_PID $COPILOT_PID 2>/dev/null
wait $WEBPACK_PID $PLAYGROUND_PID $COPILOT_PID 2>/dev/null
echo "Servers stopped."
}
# Trap SIGINT (Ctrl+C) and call cleanup
trap cleanup SIGINT
# Start Webpack dev server in the background
( cd ui && npm start ) &
WEBPACK_PID=$!
# Start PlaygroundServer if URL is provided
if [ -n "$1" ]; then
python -m server.start_playground_server --url "$1" &
PLAYGROUND_PID=$!
sleep 2
# Generate a random value
RANDOM_VALUE=$(openssl rand -hex 6)
# Construct the URL
URL="http://localhost:4000?t=$RANDOM_VALUE"
# Open the URL in the default web browser
open $URL
fi
# Start CopilotServer
python -m server.start_copilot_server &
COPILOT_PID=$!
# Wait for all background processes to complete
if [ -n "$PLAYGROUND_PID" ]; then
wait $WEBPACK_PID $PLAYGROUND_PID $COPILOT_PID
else
wait $WEBPACK_PID $COPILOT_PID
fi