haproxy/haproxy.init

116 lines
2.0 KiB
Plaintext
Raw Normal View History

2015-08-21 19:38:51 +03:00
#!/bin/sh
#
# haproxy TCP/HTTP reverse proxy for high availability environments
#
# chkconfig: - 85 15
# description: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited \
# for high availability environments.
# processname: haproxy
# config: /etc/haproxy/haproxy.conf
# pidfile: /var/run/haproxy.pid
### BEGIN INIT INFO
# Provides: haproxy
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start:
# Default-Stop:
# Short-Description: fast and reliable load balancing reverse proxy
# Description: This file should be used to start and stop haproxy.
### END INIT INFO
# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1
# Source function library.
. /etc/init.d/functions
NAME=haproxy
PIDFILE=/var/run/${NAME}.pid
CONFIG=/etc/${NAME}/${NAME}.cfg
LOCKFILE=/var/lock/subsys/${NAME}
BINARY=/usr/sbin/${NAME}
RETVAL=0
check()
{
action "Checking configuration sanity for $name: " \
$BINARY -c -q -f ${CONFIG}
RETVAL=$?
return $RETVAL
}
2015-08-21 19:38:51 +03:00
start()
{
check || exit
start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user _haproxy -- $BINARY \
2015-08-21 19:38:51 +03:00
-D -f ${CONFIG} -p ${PIDFILE}
RETVAL=$?
return $RETVAL
}
stop()
{
stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user _haproxy -- $BINARY
2015-08-21 19:38:51 +03:00
RETVAL=$?
return $RETVAL
}
restart()
{
check || exit
2015-08-21 19:38:51 +03:00
stop
start
}
reload()
{
check || exit
2015-08-21 19:38:51 +03:00
msg_reloading $NAME
$BINARY -p "$PIDFILE" -f $CONFIG -sf `cat $PIDFILE`
RETVAL=$?
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
condstop)
if [ -e "$LOCKFILE" ]; then
stop
fi
;;
condrestart)
if [ -e "$LOCKFILE" ]; then
restart
fi
;;
condreload)
if [ -e "$LOCKFILE" ]; then
reload
fi
;;
check)
check
;;
2015-08-21 19:38:51 +03:00
status)
status --pidfile "$PIDFILE" --expect-user _haproxy -- haproxy
2015-08-21 19:38:51 +03:00
RETVAL=$?
;;
*)
msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status|check}"
2015-08-21 19:38:51 +03:00
RETVAL=1
esac
exit $RETVAL