summaryrefslogtreecommitdiff
path: root/haproxy/haproxy.init
blob: 3bafd7309457e6d760773793ca30b9e8e12e1602 (plain)
    1 #!/usr/bin/env bash
    2 SSD=/sbin/start-stop-daemon
    3 PIDFILE=/var/run/haproxy.pid
    4 PROG=/usr/sbin/haproxy
    5 OPTS="-f /etc/haproxy.conf"
    6 
    7 start() { ${SSD} --start -b -m -p ${PIDFILE} -x ${PROG} -- ${OPTS}; }
    8 
    9 stop() { ${SSD} --stop --remove-pidfile --retry 10 --pidfile "${PIDFILE}"; }
   10 
   11 status() {
   12   ${SSD} --status --pidfile ${PIDFILE}
   13   case $? in
   14     0) printf 'running (pid %d)\n' "$(cat ${PIDFILE})" ;;
   15     1) printf 'stopped (stale pidfile found)\n' ;;
   16     3) printf 'stopped\n' ;;
   17     4) printf 'Unknown\n' ;;
   18   esac
   19 }
   20 
   21 case "${1}" in
   22   start)
   23     start
   24     ;;
   25   stop)
   26     stop
   27     ;;
   28   restart)
   29     stop && start
   30     ;;
   31   status)
   32     status
   33     ;;
   34   *)
   35     printf 'Action required (start, stop, restart, status)\n'
   36     ;;
   37 esac

Generated by cgit