-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAPI_Daemon.sh
42 lines (28 loc) · 930 Bytes
/
API_Daemon.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
#!/bin/bash
# Starts or ends the Reef communication APIs
if [ $# -eq 0 ]; then
printf "No arguments provided, use -h flag for help\n"
exit 1
fi
if [ $1 == "-h" ]; then
printf "Automatic API daemon set-up\n"
printf "Use flag -up to set-up the APIs\n"
printf "Use flag -down to cancel the APIs\n"
exit 1
fi
if [ $1 == "-up" ]; then
nohup /reef/new_user.py & \
> /dev/null 2>&1 & echo $! > /reef/nnuu_api.txt
nohup /reef/reef_regular.py & \
> /dev/null 2>&1 & echo $! > /reef/rerg_api.txt
nohup /reef/reef_results.py & \
> /dev/null 2>&1 & echo $! > /reef/rers_api.txt
printf "Reef APIs are now active\n"
fi
if [ $1 == "-down" ]; then
# Must compensate for the fork
kill -9 $(($(cat /reef/nnuu_api.txt) - 1))
kill -9 $(($(cat /reef/rerg_api.txt) - 1))
kill -9 $(($(cat /reef/rers_api.txt) - 1))
printf "Reef APIs have been disconnected\n"
fi