-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgin-context
executable file
·42 lines (36 loc) · 915 Bytes
/
gin-context
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
#! /bin/bash
NAME_ICON='Gin \U1F378'
SCHEDULER_ENDPOINT='127.0.0.1:50051'
executor_port_start=50052
usage() {
echo "USAGE: $0 start [num_of_executors]"
echo " $0 stop"
exit 1
}
case "$1" in
'start')
# Start Gin Scheduler
cargo run --release --quiet --bin scheduler &
while ! pgrep scheduler >/dev/null; do
echo "Waiting for scheduler to start..."
sleep 1
done
# Start Gin Executors
excs=${2:-1}
for ((i = 0; i < $excs; i++)); do
(( port = executor_port_start + i))
cargo run --release --quiet --bin executor -- 127.0.0.1:$port $SCHEDULER_ENDPOINT &
done
printf "Welcome to $NAME_ICON\n"
printf "Gin Context available at http://$SCHEDULER_ENDPOINT\n"
;;
'stop')
pkill executor && sleep 1 && pkill scheduler
printf "$NAME_ICON has stopped.\n"
;;
*)
echo "Wrong call!"
usage
exit 1
;;
esac