-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.sh
60 lines (53 loc) · 1.37 KB
/
app.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
#!/bin/sh
SERVER=false
APPLICATION=false
CURRENT_DIR=$(pwd)
SERVER_PID=""
APPLICATION_PID=""
cleanup() {
echo "Cleaning up..."
[ -n "$SERVER_PID" ] && kill "$SERVER_PID"
[ -n "$APPLICATION_PID" ] && kill "$APPLICATION_PID"
exit 0
}
trap cleanup EXIT
usage() {
echo "Usage: $0 [-s] [-a]" >&2
echo " -s, --server Use only if you want to use server as producer for broker." >&2
echo " -a, --application Use only if you want to use application as consumer for broker." >&2
exit 1
}
while [ "$#" -gt 0 ]; do
case "$1" in
-s|--server)
SERVER=true
;;
-a|--application)
APPLICATION=true
;;
-h|--help)
usage
;;
*)
usage
;;
esac
shift
done
if [ "$SERVER" = true ] && [ "$APPLICATION" = true ]; then
echo "Server and application are running now."
python3 "$CURRENT_DIR/server/server.py" &
SERVER_PID=$!
python3 "$CURRENT_DIR/modules/listener.py" &
APPLICATION_PID=$!
elif [ "$SERVER" = true ]; then
echo "Only server is running now."
gunicorn -w 1 -k gevent -b 0.0.0.0:5007 "server.server:app" --timeout 5000 &
SERVER_PID=$!
else
echo "Only application is running now."
python3 "$CURRENT_DIR/modules/listener.py" &
APPLICATION_PID=$!
fi
wait "$SERVER_PID"
wait "$APPLICATION_PID"