diff options
author | T3slider <t3slider@gmail.com> | 2015-05-20 20:27:22 +0700 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2015-05-20 20:27:47 +0700 |
commit | 49a08287360064b069cefb2fd14498a2e80e3d07 (patch) | |
tree | 938fa311319f504f1b887359ccdf4b81be1e5a54 /network/haproxy/rc.haproxy | |
parent | 4c4b36ede4cb24ecd6605ef8297f8e4c9b6513fc (diff) | |
download | slackbuilds-49a08287360064b069cefb2fd14498a2e80e3d07.tar.gz |
network/haproxy: Updated for version 1.5.12 + new maintainer.
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network/haproxy/rc.haproxy')
-rw-r--r-- | network/haproxy/rc.haproxy | 105 |
1 files changed, 79 insertions, 26 deletions
diff --git a/network/haproxy/rc.haproxy b/network/haproxy/rc.haproxy index 5663cc37a1..a95a407133 100644 --- a/network/haproxy/rc.haproxy +++ b/network/haproxy/rc.haproxy @@ -1,31 +1,84 @@ #!/bin/sh -# -# HAProxy daemon control script. -# Written for Slackware Linux by Cherife Li <cherife-#-dotimes.com>. -BIN=/usr/sbin/haproxy -CONF=/etc/haproxy/haproxy.cfg -PID=/var/run/haproxy.pid +HAPROXY=/usr/sbin/haproxy +CONFIG=/etc/haproxy/haproxy.cfg +PIDFILE=/var/run/haproxy.pid + +start() { + if [ -r $PIDFILE ]; then + echo 'HAProxy is already running!' + return + fi + $HAPROXY -f $CONFIG -D -p $PIDFILE +} + +stop() { + if [ ! -r $PIDFILE ]; then + echo 'HAProxy is not running!' + return + fi + echo "Soft-stopping HAProxy..." + kill -USR1 `cat $PIDFILE` + # Even with the right permissions the PID file will not be removed... + rm -f $PIDFILE +} + +force_stop() { + if [ ! -r $PIDFILE ]; then + echo 'HAProxy is not running!' + return + fi + echo "Hard-stopping HAProxy..." + kill `cat $PIDFILE` + # Even with the right permissions the PID file will not be removed... + rm -f $PIDFILE +} + +status() { + if [ ! -r $PIDFILE ]; then + echo "HAProxy is not running." + return + fi + PID=`cat $PIDFILE` + if [ -z "$PID" ]; then + echo 'PID file is empty! HAProxy does not appear to be running, but there is a stale PID file.' + elif kill -0 $PID; then + echo "HAProxy is running." + else + echo "HAProxy is not running, but there is a stale PID file." + fi +} + +checkconfig() { + $HAPROXY -c -q -V -f $CONFIG +} case "$1" in - check) - echo "Checking HAProxy configuration file..." - $BIN -f $CONF -cV - ;; - start) - echo "Starting HAProxy..." - $BIN -f $CONF -D -p $PID - ;; - stop) - echo "Shutting down HAProxy..." - kill -TERM `cat $PID` - rm -f $PID &> /dev/null - ;; - restart) - stop - sleep 2 - start - ;; - *) - echo "usage `basename $0` {check|start|stop|restart}" + 'start') + start + ;; + 'stop') + stop + ;; + 'force_stop') + force_stop + ;; + 'restart') + stop + start + ;; + 'force_restart') + force_stop + start + ;; + 'status') + status + ;; + 'checkconfig') + checkconfig + ;; + *) + echo "Usage: $0 {start|stop|force_stop|restart|force_restart|status|checkconfig}" + exit 1 + ;; esac |