maxwell 启动脚本

#!/bin/sh
#
# chkconfig: 345 99 01
# description: maxwell 
#
# File : maxwell
#
# Description: Starts and stops the maxwell server
#

source /etc/rc.d/init.d/functions
source /etc/profile
MAXWELL_HOME=/usr/local/webserver/maxwell-1.22.0/
MAXWELL_CONF=$MAXWELL_HOME/maxwell_test.properties
MAXWELL_PORT=9082
MAXWELL_LOG=/data/logs/maxwell-logs/maxwelllogs.log
#MAXWELL_PID=$MAXWELL_HOME/RUNNING_PID
MAXWELL_USER=root


start(){
    [ -x $MAXWELL_HOME ] || exit 5
    echo -n "Starting maxwell-xc: "
    PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'`
    if [ ! -z $PID ];then
        echo -e "    [\033[32m ok \033[0m]"
        retval=$?
        return $retval
    elif [ ! -x $MAXWELL_PID ];then
        rm -rf $MAXWELL_PID
    fi
    /sbin/runuser -s /bin/sh $MAXWELL_USER -c "$MAXWELL_HOME/bin/maxwell --bootstrapper=sync --config=$MAXWELL_CONF >>$MAXWELL_LOG 2>&1 &" 
    PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'`
    if [ -z $PID ];then
       echo -e "    [\033[32m ok \033[0m]"
       retval=$?
    else
       echo -e  "    [\033[31m Fail \033[0m]"
       alsss >/dev/null 2>&1
       retval=$?
    fi
    #[ $retval -eq 0 ] && touch $lockfile
    return $retval
}
stop(){
    [ -x $MAXWELL_HOME ] || exit 5
     echo -n "Stopping maxwell-xc: "
         
    PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'|xargs kill -9`
    for i in $(seq 10)
    do
        if [ $i -eq "10" ];then
            PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'|xargs kill -9`
        fi
        PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'|xargs kill -9`
        if [ -z $PID ];then
            echo -e "    [\033[32m ok \033[0m]"
            break
        fi
        sleep 1
    done
      
    retval=$?
    #[ $retval -eq 0 ] && touch $lockfile
    return $retval
}
status(){
    echo -n "Maxwell-xc is "
    PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'`
    if [ -z $PID ];then
        echo 'Stopped.'
    else
        echo "running $PID...."
    fi
    exit 0
}


# See how we were called.
case "$1" in

  start)
    start 
    ;;

  stop)
    stop
    ;;
  status)
    status
    ;;

  restart)
    stop
    start
    ;;

  *)
    echo "Usage: $0 {start|stop|status|restart}"
    exit 1
    ;;

esac
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值