codis启动proxy脚本

#/bin/sh

cmd=/usr/local/codis/bin/codis-proxy
conf=/etc/codis/config.ini
pid=$(ps aux | grep codis-proxy | grep -v grep | awk '{print $2}')
addr=$(ip ro li | awk '/^192/ {print $NF}')
port=19000
log=/var/log/codis/codis_proxy.log

case "$1" in
    start)
        if [ -n "$pid" ];then
            echo "${pid} exists, process is already running or crashed"
        else
            echo "Starting Codis Proxy..."
            ${cmd} -c ${conf} --cpu=1 --addr=${addr}:${port} --http-addr=192.168.1.62:1080 -L ${log} &
        fi
        ;;
    stop)
        if [ -z "$pid" ];then
            echo "pid does not exist, process is not running"
        else
            echo "Stopping ..."
            kill ${pid}
            sleep 2
            while :
            do
                new_status=$(ps aux | grep codis-proxy | grep -v grep | awk '{print $2'})
                if [ "$pid" = "$new_status" ]; then
                    echo "Waiting for codis proxy to shutdown ..."
                    sleep 1
                else
                    echo "codis proxy closed."
                    break
                fi
            done
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac

results matching ""

    No results matching ""