linux haproxy 脚本,HAproxy重启动,检查文件的脚本

HAproxy重启动,检查文件的脚本

#!/bin/bash

### BEGIN INIT INFO

#Manage the HAProxy

### END INIT INFO

bin=/usr/local/haproxy/sbin/haproxy

config=/usr/local/haproxy/conf/haproxy.cfg

pid=/usr/local/haproxy/haproxy.pid

opts=" -f ${config} -p ${pid} -D -V "

sleep_time=1

start() {

echo -e "Starting HAProxy......"

${bin} ${opts}

if [ "$?" != "0" ] ; then

sleep ${sleep_time}

echo " failed"

exit 1

else

sleep ${sleep_time}

echo " done"

fi

}

stop() {

if [ ! -e ${pid} ] ; then

echo -e "HAProxy is not running"

exit 0

fi

echo -e "Shutting down HAProxy......"

kill $(cat ${pid})

if [ -e ${pid} ] ; then

rm -f ${pid}

fi

if [ "$?" != "0" ] ; then

sleep ${sleep_time}

echo " failed"

exit 1

else

sleep ${sleep_time}

echo " done"

fi

}

reload(){

${bin} -f ${config}  -st $(cat ${pid})

echo -e "HAProxy is reload......"

}

checkconfig(){

${bin} -c -f ${config}

echo -e "haproxy file is ok"

}

restart() {

stop

start

}

case "$1" in

start)

start

;;

stop)

stop

;;

restart)

restart

;;

reload)

reload

;;

checkconfig)

checkconfig

;;

*)

echo "Usage: $0 {start|stop|restart|reload|checkconfig}"

exit 1

;;

esac

HAproxy 的详细介绍:请点这里

HAproxy 的下载地址:请点这里

推荐阅读:

0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值