Created
August 31, 2014 07:15
-
-
Save lokielse/0db67a01ff95d4dae24e to your computer and use it in GitHub Desktop.
HAProxy boot start init file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# chkconfig 2345 on | |
# description: HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments. | |
if [ -f /etc/init.d/functions ]; then | |
. /etc/init.d/functions | |
elif [ -f /etc/rc.d/init.d/functions ] ; then | |
. /etc/rc.d/init.d/functions | |
elif [ -f /lib/lsb/init-functions ] ; then | |
. /lib/lsb/init-functions | |
else | |
echo 'functions not found' | |
exit 0 | |
fi | |
# Source networking configuration. | |
#. /etc/sysconfig/network | |
# Check that networking is up. | |
#[ ${NETWORKING} = "no" ] && exit 0 | |
config="/usr/local/haproxy/conf/haproxy.cfg" | |
exec="/usr/local/sbin/haproxy" | |
PID="/var/run/haproxy.pid" | |
[ -f $config ] || exit 1 | |
RETVAL=0 | |
start() { | |
start_daemon $exec -c -q -f $config | |
if [ $? -ne 0 ]; then | |
echo "Errors found in configuration file." | |
return 1 | |
fi | |
echo -n "Starting HAproxy:..." | |
$exec -D -f $config -p $PID | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/haproxy | |
return $RETVAL | |
} | |
stop() { | |
echo -n "Shutting down HAproxy... " | |
killproc haproxy -USR1 | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/haproxy | |
[ $RETVAL -eq 0 ] && rm -f $PID | |
return $RETVAL | |
} | |
restart() { | |
$exec -c -q -f $config | |
if [ $? -ne 0 ]; then | |
echo "Errors found in configuration file, check it with 'haproxy check'." | |
return 1 | |
fi | |
stop | |
start | |
} | |
rhstatus() { | |
status haproxy | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
status) | |
rhstatus | |
;; | |
*) | |
echo $"Usage: haproxy {start|stop|restart|status}" | |
RETVAL=1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mkdir 0755 /var/lock/subsys/