aboutsummaryrefslogtreecommitdiff
path: root/net/haproxy-devel/files
diff options
context:
space:
mode:
authorClement Laforet <clement@FreeBSD.org>2004-06-08 10:31:00 +0000
committerClement Laforet <clement@FreeBSD.org>2004-06-08 10:31:00 +0000
commitc62a21e3581d3635d271cb94f0db481b7893cd6f (patch)
tree6f8ea1c9d84a07e531f664fb5bf88cca14bcd92e /net/haproxy-devel/files
parent5ae350cd7e6b6cd85a700d5d22b83798acc54229 (diff)
downloadports-c62a21e3581d3635d271cb94f0db481b7893cd6f.tar.gz
ports-c62a21e3581d3635d271cb94f0db481b7893cd6f.zip
Notes
Diffstat (limited to 'net/haproxy-devel/files')
-rw-r--r--net/haproxy-devel/files/haproxy.sh68
1 files changed, 48 insertions, 20 deletions
diff --git a/net/haproxy-devel/files/haproxy.sh b/net/haproxy-devel/files/haproxy.sh
index e51b6a855662..3b633d089d7b 100644
--- a/net/haproxy-devel/files/haproxy.sh
+++ b/net/haproxy-devel/files/haproxy.sh
@@ -1,22 +1,50 @@
#!/bin/sh
+#
+# $FreeBSD$
+#
-if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
- echo "$0: Cannot determine the PREFIX" >&2
- exit 1
-fi
-
-case "$1" in
- start)
- [ -x ${PREFIX}/sbin/haproxy ] && \
- [ -r ${PREFIX}/etc/haproxy.cfg ] && \
- ${PREFIX}/sbin/haproxy -f ${PREFIX}/etc/haproxy.cfg && \
- echo -n ' haproxy'
-
- ;;
- stop)
- killall haproxy && echo -n ' haproxy'
- ;;
- *)
- echo "Usage: `basename $0` {start|stop}" >&2
- ;;
-esac
+# PROVIDE: haproxy
+# REQUIRE: NETWORKING SERVERS
+# BEFORE: DAEMON
+# KEYWORD: FreeBSD shutdown
+
+#
+# Add the following lines to /etc/rc.conf to enable haproxy:
+# haproxy_enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable haproxy
+# haproxylimits_enable (bool):Set to "NO" by default.
+# Set it to yes to run `limits $limits_args`
+# just before haproxy starts.
+# haproxy_flags (str): Set to "" by default.
+# Extra flags passed to start command
+# haproxylimits_args (str): Default to "-e -C daemon"
+# Arguments of pre-start limits run.
+#
+. %%RC_SUBR%%
+
+name="haproxy"
+rcvar=`set_rcvar`
+
+command="%%PREFIX%%/sbin/haproxy"
+pidfile="/var/run/haproxy.pid"
+required_files=%%PREFIX%%/etc/haproxy.conf
+
+[ -z "$haproxy_enable" ] && haproxy_enable="NO"
+[ -z "$haproxy_flags" ] && haproxy_flags="-p ${pidfile}"
+[ -z "$haproxylimits_enable" ] && haproxylimits_enable="NO"
+[ -z "$haproxylimits_args" ] && haproxylimits_args="-e -C daemon"
+
+load_rc_config $name
+
+checkyesno haproxylimits_enable && \
+ start_precmd="eval `/usr/bin/limits ${haproxylimits_args}` 2>/dev/null"
+
+sig_gracefulstop=SIGUSR1
+
+haproxy_gracefulstop() {
+ echo "Gracefully shutdown haproxy ($rc_pid)"
+ kill -${sig_gracefulstop} ${rc_pid}
+ }
+
+extra_commands="gracefulstop"
+run_rc_command "$1"