-
Notifications
You must be signed in to change notification settings - Fork 499
/
stop.sh
executable file
·54 lines (41 loc) · 1.05 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
#!/bin/bash
APPDIR=`dirname $0`
pushd $APPDIR > /dev/null
APPDIR=`pwd`
server=$APPDIR/bin/easegress-server
cfgfile=$APPDIR/conf/config.yaml
pid=`ps -eo pid,args | grep "$server" | grep -v grep | awk '{print $1}'`
if [ -n "$pid" ]
then
alive="yes"
else
alive="no"
fi
if [ "$alive" = "no" ]
then
exit 0
fi
if [ "$1" = "-f" ]
then
kill -9 $pid
exit 0
fi
RED='\033[0;31m'
NC='\033[0m' # No Color
total_etcd=`./status.sh | grep primary | wc -l`
online=`./status.sh | grep primary | grep online | wc -l`
if [ $online -le $((total_etcd / 2 + 1)) ]
then
if [ "$1" != "-f" ]
then
echo -e "total etcd members: ${RED}$total_etcd${NC}, online members: ${RED}$online${NC}, I am alive: ${RED}$alive${NC}"
echo -e "${RED}Stop this node will cause the etcd unavailable${NC}"
echo -e "Run ${RED}$0 -f${NC} if you really wanna to proceed"
exit 1
fi
fi
pid=`ps -eo pid,args | grep "$server" | grep -v grep | awk '{print $1}'`
if [ ! -z $pid ];then
kill -9 $pid
fi
popd > /dev/null