summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Ruppert <idl0r@gentoo.org>2022-07-26 10:13:20 +0200
committerChristian Ruppert <idl0r@gentoo.org>2022-07-26 10:28:28 +0200
commit3233b24b3e882edea9ad2752650baf1506b0ccc0 (patch)
tree96a74b773b10690e106f7362a3f73a579a6522f2 /net-proxy/haproxy/files
parentwww-client/firefox-bin: add 91.12.0, drop 91.11.0 (diff)
downloadgentoo-3233b24b3e882edea9ad2752650baf1506b0ccc0.tar.gz
gentoo-3233b24b3e882edea9ad2752650baf1506b0ccc0.tar.bz2
gentoo-3233b24b3e882edea9ad2752650baf1506b0ccc0.zip
net-proxy/haproxy: Fix reloading and use master-CLI
Package-Manager: Portage-3.0.30, Repoman-3.0.3 Signed-off-by: Christian Ruppert <idl0r@gentoo.org>
Diffstat (limited to 'net-proxy/haproxy/files')
-rw-r--r--net-proxy/haproxy/files/haproxy.confd-r114
-rw-r--r--net-proxy/haproxy/files/haproxy.initd-r885
2 files changed, 99 insertions, 0 deletions
diff --git a/net-proxy/haproxy/files/haproxy.confd-r1 b/net-proxy/haproxy/files/haproxy.confd-r1
new file mode 100644
index 000000000000..b9bb84e3e833
--- /dev/null
+++ b/net-proxy/haproxy/files/haproxy.confd-r1
@@ -0,0 +1,14 @@
+# HAProxy config file(s), space separated
+#CONFIGS="/etc/haproxy/haproxy.cfg"
+
+# Additional HAProxy command line options
+HAPROXY_OPTS="-S /run/haproxy-master.sock"
+
+# If you want to make use ot the new seamless reload you can just write your own
+# reload_seamless function here. It will be called by the init script.
+# For more information on how to use that feature please have a look at the
+# "seamless_reload.txt" documentation file (requires net-proxy/haproxy[examples])
+#reload_seamless() {
+# checkpath -d -m 0700 haproxy:haproxy "/run/haproxy/"
+# socat /run/haproxy/socket - <<< "show servers state" > /run/haproxy/global.state
+#}
diff --git a/net-proxy/haproxy/files/haproxy.initd-r8 b/net-proxy/haproxy/files/haproxy.initd-r8
new file mode 100644
index 000000000000..4994c28b42d5
--- /dev/null
+++ b/net-proxy/haproxy/files/haproxy.initd-r8
@@ -0,0 +1,85 @@
+#!/sbin/openrc-run
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+extra_commands="checkconfig"
+extra_started_commands="reload"
+
+command="/usr/sbin/haproxy"
+
+pidfile="${HAPROXY_PIDFILE:-/run/${SVCNAME}.pid}"
+
+configs=
+
+if [ -z "${CONFIGS}" ]; then
+ if [ -f "/etc/haproxy/${SVCNAME}.cfg" ]; then
+ CONFIGS=/etc/haproxy/${SVCNAME}.cfg
+ elif [ -f "/etc/${SVCNAME}.cfg" ]; then
+ CONFIGS=/etc/${SVCNAME}.cfg # Deprecated
+ fi
+fi
+
+for conf in $CONFIGS; do
+ configs="${configs} -f ${conf}"
+done
+
+command_args="-D -W -p ${pidfile} ${configs} ${HAPROXY_OPTS}"
+
+depend() {
+ need net
+ use dns logger
+}
+
+checkconfig() {
+ if [ -z "${CONFIGS}" ]; then
+ eerror "No config(s) has been specified"
+ return 1
+ fi
+
+ for conf in $CONFIGS; do
+ if [ ! -f "${conf}" ]; then
+ eerror "${conf} does not exist!"
+ return 1
+ fi
+ done
+
+ ebegin "Checking ${CONFIGS}"
+ $command -q -c $configs $HAPROXY_OPTS
+ eend $?
+}
+
+start_pre() {
+ if [ "${RC_CMD}" != "restart" ]; then
+ checkconfig || return 1
+ fi
+}
+
+stop_pre() {
+ if [ "${RC_CMD}" = "restart" ]; then
+ checkconfig || return 1
+ fi
+}
+
+stop() {
+ local _t _pid
+
+ _t="$(mktemp)"
+ for _pid in $(cat ${pidfile}) ; do
+ echo "${_pid}" > "${_t}"
+ start-stop-daemon --stop --pidfile="${_t}"
+ done
+ rm -f "${_t}"
+}
+
+reload() {
+ checkconfig || { eerror "Reloading failed, please fix your config(s) first"; return 1; }
+
+ if [ "$(command -v reload_seamless)" = "reload_seamless" ]; then
+ einfo "Calling user-defined reload_seamless()"
+ reload_seamless || { eerror "reload_seamless() failed!"; return 1; }
+ fi
+
+ ebegin "Reloading ${SVCNAME}"
+ $command $command_args -sf $(cat "${pidfile}")
+ eend $?
+}