scplt推送服务监控脚本

scplt推送服务监控脚本

cat push_server_issue_monitor 

#!/bin/bash
# Author: royoy
# Desc: push_server_issue_monitor
#   status start stop script

PHP="/usr/local/php/bin/php"
QUEUE="/www/releases/product_v1/bin/issue_monitor"
REDIS_ISSUE="--redis_conf=redis://@10.9.119.213:6379/5"
LOG="/data/logs/push_server_issue_monitor.log"

stop(){
echo -en "Push_Server_issue_monitor stop\t "
while :
do
[ "`ps -ef |grep 'issue_monitor' |wc -l`" -gt 1 ] && {
        ps -ef |grep 'issue_monitor' |awk '!/grep/{print $2}' |xargs kill 
        sleep 2
} || {
        echo -en "Failed\nPush_Server_issue_monitor not running\n"
        exit 9
}
done
echo -en "\033[32mOK\033[0m\n"
}

start(){
[ "`ps -ef |grep 'issue_monitor' |wc -l`" -gt 1 ] && {
        echo "Push_Server_issue_monitor is running"
        exit 9
} || {
echo -en "Push_Server_issue_monitor start\t "
while :
do
nohup $PHP $QUEUE $REDIS_ISSUE &>>$LOG &
sleep 2
[ "`ps -ef |grep 'issue_monitor' |wc -l`" -gt 1 ] && {
        break
}
done
echo -en "\033[32mOK\033[0m\n"
}
}

status(){
[ "`ps -ef |grep 'issue_monitor' |wc -l`" -gt 1 ] && {
        echo "Push_Server_issue_monitor is running"
        exit 0
} || {
        echo "Push_Server_issue_monitor is stopped"
        exit 0
}
}

case $1 in
        start)
        start
        ;;
        stop)
        stop
        ;;
        status)
        status
        ;;
        *)
        echo -en "Usage: \033[33m$0 (status|start|stop)\033[0m\n"
        ;;
esac

exit $?