美文网首页
一个sentinel启动关闭的shell示例

一个sentinel启动关闭的shell示例

作者: holyABCD | 来源:发表于2018-03-20 20:27 被阅读0次
    
    #!/bin/bash
    
    Sentinel_bin_server=/usr/local/redis/bin/redis-sentinel
    
    Sentinel_conf=/data/sentinel$1/$1.conf
    
    port=$1
    
    source /etc/init.d/functions
    
    sentinel_start() {
    
            if $($Sentinel_bin_server $Sentinel_conf)
    
            then
    
                    pid=`ps aux |grep redis-sentinel |grep $port| grep -v grep |awk '{print $2}'`
    
                    echo -n "Port:$port sentinel is running, pid:$pid"
    
                    success
    
                    echo
    
            else
    
                    echo -n "Port:$port sentinel is running!"
    
                    failure
    
                    echo
    
                fi
    
    }
    
    sentinel_stop() {
    
            pid=`ps aux |grep redis-sentinel |grep $port| grep -v grep |awk '{print $2}'`
    
            if kill -9 $pid
    
            then
    
                    echo -n "Port:$port sentinel is stopped!"
    
                    success
    
                    echo
    
            else
    
                    echo -n "Port:$port sentinel is stopped!"
    
                    failure
    
                    echo
    
                fi
    
    }
    
    sentinel_restart(){
    
            sentinel_stop
    
            sleep 1
    
            sentinel_start
    
    }
    
    sentinel_usage() {
    
            echo -e "Usage: $0 {port} {start,stop,restart}"
    
            exit 1
    
    }
    
    case "$2" in
    
      start) sentinel_start ;;
    
      stop)  sentinel_stop  ;;
    
      restart) sentinel_restart ;;
    
      *)    sentinel_usage ;;
    
    esac
    
    

    相关文章

      网友评论

          本文标题:一个sentinel启动关闭的shell示例

          本文链接:https://www.haomeiwen.com/subject/oqciqftx.html