-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathstart-team.sh
executable file
·94 lines (79 loc) · 1.96 KB
/
start-team.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# create a log directory with the current date and time
log_dir="logs/$(date +'%Y-%m-%d_%H-%M-%S')"
if [ ! -d $log_dir ]; then
mkdir -p $log_dir
fi
abs_log_dir_path=$(realpath $log_dir)
# Ensure the script exits if any command fails
set -e
# check scripts/proxy directory does not exist, raise error
if [! -d scripts/proxy ]; then
echo "scripts/proxy directory does not exist"
exit 1
fi
team_name="CLS"
rpc_port=50051
debug=false
# help function
usage() {
echo "Usage: $0 [options]"
echo "Options:"
echo " -t team_name: specify team name"
echo " --rpc-port PORT - specifies rpc port (default: 50051)"
exit 1
}
while [ $# -gt 0 ]
do
case $1 in
-t)
team_name=$2
shift
;;
--rpc-port)
rpc_port=$2
shift
;;
-d|--debug)
debug=true
;;
*)
echo 1>&2
echo "invalid option \"${1}\"." 1>&2
echo 1>&2
usage
exit 1
;;
esac
shift 1
done
# Check Python requirements
echo "Checking Python requirements..."
python3 check_requirements.py
# Start server.py in the background
echo "Starting server.py..."
python3 server.py --rpc-port $rpc_port --log-dir $abs_log_dir_path &
server_pid=$!
# Function to kill server and team processes on exit
cleanup() {
echo "Cleaning up..."
kill $server_pid
kill $start_pid
}
# Trap the exit signal to cleanup processes
trap cleanup EXIT
# Wait a moment to ensure the server has started (optional)
sleep 2
# Start start.sh script in the correct directory with arguments
echo "Starting start.sh with team name: $team_name and ..."
start_log_path="$abs_log_dir_path/proxy.log"
cd scripts/proxy
if [ "$debug" = true ]; then
bash start-debug.sh -t "$team_name" --rpc-port $rpc_port --rpc-type grpc >> $start_log_path 2>&1 &
else
bash start.sh -t "$team_name" --rpc-port $rpc_port --rpc-type grpc >> $start_log_path 2>&1 &
fi
start_pid=$!
# Wait for both background processes to finish
wait $server_pid
wait $start_pid