-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.sh
47 lines (39 loc) · 882 Bytes
/
check.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
#!/bin/bash
# desc: for project start|stop|pack
# * * * * * /usr/local/monitor/log/check.sh start &> /dev/null
DIR="/usr/local/monitor/log"
APP="es-index-monitor"
CFG="cfg.yaml"
chmod +x ${DIR}/${APP} &> /dev/null
function stop(){
ps aux |grep ${APP} | egrep -v "${DIR}|grep" | awk '{print $2}' | xargs kill
}
function start(){
num=`ps aux | grep ${APP} | egrep -v "${DIR}|grep" | wc -l`
if [[ $num < 1 ]];then
cd ${DIR}
cp -rf ./log ./log.old
./${APP} -c ./${CFG} &> ./log &
echo "start ok"
exit
fi
echo "${APP} already running"
}
function pack() {
export GOOS=linux
go build .
tar zcvf es-index-monitor-`date +%F`.tgz es-index-monitor cfg.yaml check.sh
rm -rf es-index-monitor
}
if [ $# != 1 ];then
echo "usage: ./check.sh start|stop|pack"
exit
fi
case $1 in
start)
start;;
stop)
stop;;
pack)
pack;;
esac