summaryrefslogtreecommitdiff
path: root/net/haproxy/files/haproxy.in
diff options
context:
space:
mode:
authorWen Heping <wen@FreeBSD.org>2010-03-16 01:39:45 +0000
committerWen Heping <wen@FreeBSD.org>2010-03-16 01:39:45 +0000
commitb9f63461f097034814eebed346fd2b04bb06fe13 (patch)
treeb707464e5edb8facdb1f20b8a06c65e8e7e4474d /net/haproxy/files/haproxy.in
parent- Update to 2.19 (diff)
- Update to 1.4.1
- Pass maintainer to submitter PR: ports/144331 Submitted by: Ross West <freebsd@linepoint.com> (new maintainer)
Diffstat (limited to 'net/haproxy/files/haproxy.in')
-rw-r--r--net/haproxy/files/haproxy.in99
1 files changed, 99 insertions, 0 deletions
diff --git a/net/haproxy/files/haproxy.in b/net/haproxy/files/haproxy.in
new file mode 100644
index 000000000000..69991093ed52
--- /dev/null
+++ b/net/haproxy/files/haproxy.in
@@ -0,0 +1,99 @@
+#!/bin/sh
+
+# PROVIDE: haproxy
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+#######
+#
+# Add the following lines to /etc/rc.conf to enable haproxy:
+#
+# haproxy_enable (bool): default: "NO"
+# Set to "YES" to enable haproxy
+# haproxy_pidfile (str): default: /var/run/${name}.pid
+# Set to the full path of the pid file
+# haproxy_config (str): default: /usr/local/etc/${name}.conf
+# Set to the full path of the config file
+# haproxy_flags (str): default: Autogenerated using pidfile and config options
+# Set to override with your own options
+#
+#######
+#
+# rc.d Script Runtime Options:
+#
+# start - starts application normally
+# stop - (softstop) stops all proxies and exits once all sessions are closed
+# forcestop - (immediate) stops all proxies and kills active sessions
+# reload - hot-reconfig using "-sf" option (active sessions kept)
+# forcereload - hot-reconfig using "-st" option (active sessions killed)
+# restart - equiv to "stop" then "start"
+# checkconfig - checks configuration file defined in haproxy_config
+#
+#######
+
+. %%RC_SUBR%%
+
+name="haproxy"
+rcvar=`set_rcvar`
+command="%%PREFIX%%/sbin/haproxy"
+
+# Load Configs/Set Defaults
+load_rc_config $name
+: ${haproxy_enable:="NO"}
+: ${haproxy_config:="%%PREFIX%%/etc/${name}.conf"}
+: ${haproxy_pidfile:="/var/run/${name}.pid"}
+: ${haproxy_flags="-q -f ${haproxy_config} -p ${haproxy_pidfile}"}
+
+# Update the globals
+pidfile=${haproxy_pidfile}
+required_files=${haproxy_config}
+
+# Commands: start, stop, restart, reload, checkconfig
+extra_commands="reload checkconfig"
+
+checkconfig_cmd="haproxy_checkconfig"
+reload_cmd="haproxy_reload"
+
+haproxy_reload()
+{
+ # Check configuration file quietly first
+ ${command} -q -c -f ${haproxy_config}
+ if [ $? -ne 0 ]; then
+ echo "Error found in ${haproxy_config} - not reloading current process!"
+ return
+ fi
+ rc_pid=$(check_pidfile ${haproxy_pidfile} ${command})
+ if [ $rc_pid ]; then
+ if [ $rc_force ]; then
+ ${command} ${haproxy_flags} -st ${rc_pid}
+ else
+ ${command} ${haproxy_flags} -sf ${rc_pid}
+ fi
+ else
+ echo "No process found. Maybe $command isn't running?"
+ fi
+}
+
+haproxy_checkconfig()
+{
+ ${command} -c -f ${haproxy_config}
+}
+
+haproxy_prestart()
+{
+ ${command} -q -c -f ${haproxy_config}
+ rc_flags=${haproxy_flags}
+}
+
+haproxy_prestop()
+{
+ # SIGUSR1 = softstop, SIGTERM = faststop
+ if [ $rc_force ]; then
+ sig_stop="SIGTERM"
+ else
+ sig_stop="SIGUSR1"
+ fi
+}
+
+
+run_rc_command "$1"