-
Notifications
You must be signed in to change notification settings - Fork 6
/
run.sh
executable file
·41 lines (31 loc) · 772 Bytes
/
run.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
#!/bin/bash
# make and enter build directory
mkdir -p build
cd build || exit
# build project
cmake ..
# if successfully compiled with multiple threads
if make -j8; then
# start server in background and print its output to the console
./server &
server_pid=$!
sleep 3
# start all clients in background
./price &
./trade &
./market &
./inquiry &
# trap SIGINT and terminate all processes
trap 'kill $server_pid; pkill -P $$; exit' SIGINT
# you can press any key to terminate all processes
read -p "Press any key to terminate all processes." -n 1 -r
echo
# wait all processes to exit
wait
# kill all processes
kill $server_pid
pkill -P $$
cd ..
else
echo "Build failed"
fi