[codesyntax lang=”python”]
#!/bin/bash #created by teddylu on 2014-1-15 #used for haproxy-1.4.26 BASE="/application/haproxy" PROG=$BASE/sbin/haproxy PIDFILE=$BASE/var/run/haproxy.pid CONFFILE=$BASE/conf/haproxy.conf case "$1" in start) ??????? #$PROG -f $CONFFILE >/dev/null 2>&1 ??????? $PROG -f $CONFFILE ??????? ;; status) ??????? if [ ! -f $PIDFILE ]; then ??????????????? echo "pid not found" ??????????????? exit 1 ??????? fi ??????? for pid in $(cat $PIDFILE); do ??????????????? kill -0 $pid ??????????????? RETVAL="$?" ??????????????? if [ ! "$RETVAL" = "0" ]; then ??????????????????????? echo "process $pid died" ??????????????????????? exit 1 ??????????????? fi ??????? done ??????? echo "process is running" ??????? ;; restart) ??????? $PROG -f $CONFFILE -sf $(cat $PIDFILE) >/dev/null 2>&1 ??????? ;; stop) ??????? kill $(cat $PIDFILE) ??????? ;; *) ??????? echo "USAGE: $0 start|restart|status|stop" ??????? exit 1 ??????? ;; esac
[/codesyntax]
#启动haproxy
/application/haproxy/bin/haproxy start
[root@haproxy_01 teddylu]# netstat -lntp|grep haproxy
tcp??????? 0????? 0 192.168.1.104:80??????????? 0.0.0.0:*?????????????????? LISTEN????? 6035/haproxy
开发haproxy启动脚本