-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.sh
executable file
·120 lines (102 loc) · 2.2 KB
/
status.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
#!/bin/bash
red='\033[1;31m'
green='\033[1;32m'
default='\033[0m'
_ps_status() {
if [ $# -ne 1 ]; then
echo "needs process-name or string"
exit 1
fi
ps -ef | grep "$1" | grep -v grep | awk 'BEGIN{status=1} { print $2; status=0 } END{exit status}' &>/dev/null && \
printf "$green%20.20s$default\n" "[ RUNNING ]" || printf "$red%20.20s$default\n" "[ NOT RUNNING ]"
}
backend_status() {
printf "%-40s" "backend flask servers ... " && \
_ps_status 'community-discussion/venv/bin/flask'
}
chat_status() {
printf "%-40s" "backend chat server ..." && \
_ps_status 'chat/app.py'
}
frontend_status() {
printf "%-40s" "frontend node server ... " && \
_ps_status 'community-discussion/frontend/node_modules/.bin/vue-cli-service'
}
_docker_service_status() {
if [ $# -eq 0 ]; then
return
fi
printf "%-40s" "$1 service ... " && \
docker ps -a | grep -q $1 && \
printf "$green%20.20s$default\n" "[ RUNNING ]" || printf "$red%20.20s$default\n" "[ NOT RUNNING ]"
}
mongo_status() {
_docker_service_status "mongo"
}
kafka_status() {
_docker_service_status kafka
_docker_service_status zookeeper
}
spark_status() {
_docker_service_status "spark-master"
_docker_service_status "spark-worker"
}
sparkbatch_status() {
printf "%-40s" "spark batch ... " && \
_ps_status 'spark-batch'
}
sparkspeed_status() {
printf "%-40s" "spark speed ... " && \
_ps_status 'spark-speed'
}
elasticsearch_status() {
_docker_service_status 'elasticsearch'
}
kibana_status() {
_docker_service_status 'kibana'
}
logs_status() {
printf "%-40s" "logs ... " && \
_ps_status 'logs/c18n.log'
}
if [ $# -eq 1 -a "$1" = '-h' ]; then
cat <<EOF
usage
$0
status of all the components.
$0 component [component] ...
status of only the given component(s)
components can be one of:
mongo
kafka
spark
sparkspeed
sparkbatch
elasticsearch
kibana
backend
frontend
logs
EOF
exit 0
fi
case $# in
0)
kafka_status
spark_status
sparkbatch_status
sparkspeed_status
mongo_status
elasticsearch_status
kibana_status
backend_status
chat_status
frontend_status
logs_status
;;
*)
for i in $@ ; do
${i}_status
done
;;
esac