scplt推送服务队列管理脚本

scplt推送服务队列管理脚本

cat push_server_queue_manager 

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

PHP="/usr/local/php/bin/php"
QUEUE="/www/releases/product_v1/bin/queue_manager"
LOG="/data/logs/push_server_queue_manager.log"
REDIS_QUEUE="--redis_conf=redis://@10.9.119.213:6379/0"

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

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

status(){
[ "`ps -ef |grep 'queue_manager --interval=1 --queue=sc_queue_default' |wc -l`" -gt 1 ] && {
        echo "Push_Server_queue_manager is running"
        exit 0
} || {
        echo "Push_Server_queue_manager 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 $?