-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop.sh
executable file
·124 lines (104 loc) · 2.35 KB
/
stop.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
red='\033[1;31m'
green='\033[1;32m'
default='\033[0m'
_kill_with_exit_status() {
if [ $# -ne 1 ]; then
echo "needs process-name or string"
exit 1
fi
kill -9 $(ps -ef | grep "$1" | grep -v grep | awk 'BEGIN{status=1} { print $2; status=0 } END{exit status}') 2>/dev/null && \
printf "$green%10.10s$default\n" "[ OK ]" || printf "$red%10.10s$default\n" "[ FAILED ]"
}
stop_backend() {
printf "%-40s" "stopping backend flask servers ... " && \
_kill_with_exit_status 'community-discussion/venv/bin/flask'
}
stop_chat() {
printf "%-40s" "stopping backend chat server ..." && \
_kill_with_exit_status 'chat/app.py'
}
stop_frontend() {
printf "%-40s" "stopping frontend node server ... " && \
_kill_with_exit_status 'community-discussion/frontend/node_modules/.bin/vue-cli-service'
}
_stop_service() {
if [ $# -eq 0 ]; then
return
fi
printf "%-40s" "stopping $1 service ... " && \
docker stop $1 2>/dev/null && \
printf "$green%10.10s$default\n" "[ OK ]" || printf "$red%10.10s$default\n" "[ FAILED ]"
}
stop_mongo() {
_stop_service "mongo"
}
stop_kafka() {
_stop_service "kafka"
_stop_service "zookeeper"
}
stop_spark() {
_stop_service "spark-master"
_stop_service "spark-worker"
}
stop_logs() {
printf "%-40s" "stopping logs ... " && \
_kill_with_exit_status 'logs/c18n.log'
}
stop_sparkspeed() {
printf "%-40s" "stopping spark speed processes ... " && \
_kill_with_exit_status 'spark-speed.py'
printf "%-40s" "stopping spark-shell ... " && \
_kill_with_exit_status 'spark-shell'
}
stop_sparkbatch() {
printf "%-40s" "stopping spark batch processes ... " && \
_kill_with_exit_status 'spark-batch.py'
}
stop_elasticsearch() {
_stop_service 'elasticsearch'
}
stop_kibana() {
_stop_service 'kibana'
}
if [ $# -eq 1 -a "$1" = '-h' ]; then
cat <<EOF
usage
$0
stop all the components.
$0 component [component] ...
stop only the given component(s)
components can be one of:
mongo
kafka
spark (container service)
sparkbatch
sparkspeed
elasticsearch
kibana
backend
frontend
logs
EOF
exit 0
fi
case $# in
0)
stop_kafka
stop_spark
stop_sparkbatch
stop_sparkspeed
stop_mongo
stop_elasticsearch
stop_kibana
stop_backend
stop_chat
stop_frontend
stop_logs
;;
*)
for i in $@ ; do
stop_$i
done
;;
esac