aboutsummaryrefslogtreecommitdiff
path: root/net/haproxy20/files
diff options
context:
space:
mode:
authorDmitry Sivachenko <demon@FreeBSD.org>2020-07-26 07:55:23 +0000
committerDmitry Sivachenko <demon@FreeBSD.org>2020-07-26 07:55:23 +0000
commitaa98590043367b696ca7bb5e68e2e39e2ae27c40 (patch)
tree3c405d6bfe50e0ec44c938c5b560f5060f858585 /net/haproxy20/files
parent37a49a023d6802b263ae23cbad150f1187f3defc (diff)
downloadports-aa98590043367b696ca7bb5e68e2e39e2ae27c40.tar.gz
ports-aa98590043367b696ca7bb5e68e2e39e2ae27c40.zip
Separate 2.0 version of haproxy into it's own port,
haproxy will track 2.1 branch now.
Notes
Notes: svn path=/head/; revision=543441
Diffstat (limited to 'net/haproxy20/files')
-rw-r--r--net/haproxy20/files/haproxy.in133
-rw-r--r--net/haproxy20/files/patch-include-common-hathreads.h11
2 files changed, 144 insertions, 0 deletions
diff --git a/net/haproxy20/files/haproxy.in b/net/haproxy20/files/haproxy.in
new file mode 100644
index 000000000000..c3413a8c8829
--- /dev/null
+++ b/net/haproxy20/files/haproxy.in
@@ -0,0 +1,133 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: haproxy
+# REQUIRE: DAEMON LOGIN
+# 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/haproxy.pid
+# Set to the full path of the pid file
+# haproxy_config (str): default: %%PREFIX%%/etc/haproxy.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
+# haproxy_profiles (str): default: empty
+# Set to space-separated list of profiles: for each profile separate haproxy
+# process will be spawned, with haproxy-${profile}.conf config file.
+# You can override default pidfile and config file for each profile with
+# haproxy_${profile}_config and haproxy_${profile}_pidfile.
+
+. /etc/rc.subr
+
+name="haproxy"
+rcvar=haproxy_enable
+command="%%PREFIX%%/sbin/haproxy"
+extra_commands="reload configtest hardstop hardreload softreload"
+reload_cmd="haproxy_reload"
+hardreload_cmd="haproxy_reload"
+hardreload_precmd="def_hardreload_option"
+softreload_cmd="haproxy_reload"
+softreload_precmd="def_softreload_option"
+stop_cmd="haproxy_stop"
+hardstop_cmd="haproxy_stop"
+hardstop_precmd="def_hardstop_signal"
+
+: ${haproxy_enable:="NO"}
+: ${haproxy_config:="%%PREFIX%%/etc/${name}.conf"}
+: ${haproxy_socket:="/var/run/${name}/socket"}
+pidfile=${haproxy_pidfile:-"/var/run/haproxy.pid"}
+
+def_hardreload_option()
+{
+ reload_opt="-st"
+}
+
+def_softreload_option()
+{
+ reload_opt="-x ${haproxy_socket} -sf"
+}
+
+def_hardstop_signal()
+{
+ sig_stop="TERM"
+}
+
+load_rc_config $name
+
+is_valid_profile() {
+ local profile
+ for profile in $haproxy_profiles; do
+ if [ "$profile" = "$1" ]; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+if [ -n "$2" ]; then
+ profile=$2
+ if ! is_valid_profile $profile; then
+ echo "$0: no such profile ($profile) defined in ${name}_profiles."
+ exit 1
+ fi
+ eval haproxy_config="\${haproxy_${profile}_config:-%%PREFIX%%/etc/haproxy-${profile}.conf}"
+ eval pidfile="\${haproxy_${profile}_pidfile:-/var/run/haproxy-${profile}.pid}"
+else
+ if [ "x${haproxy_profiles}" != "x" -a "x$1" != "x" ]; then
+ for profile in ${haproxy_profiles}; do
+ echo "===> ${name} profile: ${profile}"
+ %%PREFIX%%/etc/rc.d/haproxy $1 ${profile}
+ retcode="$?"
+ if [ ${retcode} -ne 0 ]; then
+ failed="${profile} (${retcode}) ${failed:-}"
+ else
+ success="${profile} ${success:-}"
+ fi
+ done
+ exit 0
+ fi
+fi
+
+: ${haproxy_flags:="-q -f ${haproxy_config} -p ${pidfile}"}
+configtest_cmd="$command -c -f $haproxy_config"
+start_precmd="$command -q -c -f $haproxy_config"
+required_files=$haproxy_config
+sig_stop=SIGUSR1
+reload_opt="-sf"
+
+haproxy_reload()
+{
+ ${command} -q -c -f ${haproxy_config}
+ if [ $? -ne 0 ]; then
+ err 1 "Error found in ${haproxy_config} - not reloading current process!"
+ fi
+ rc_pid=$(check_pidfile ${pidfile} ${command})
+ if [ $rc_pid ]; then
+ ${command} ${haproxy_flags} $reload_opt $(cat ${pidfile})
+ else
+ _run_rc_notrunning
+ return 1
+ fi
+}
+
+haproxy_stop()
+{
+ rc_pid=$(check_pidfile ${pidfile} ${command})
+ if [ $rc_pid ]; then
+ rc_pid=$(cat ${pidfile})
+ kill -$sig_stop $rc_pid
+ wait_for_pids $rc_pid
+ else
+ _run_rc_notrunning
+ return 1
+ fi
+}
+
+run_rc_command "$1"
diff --git a/net/haproxy20/files/patch-include-common-hathreads.h b/net/haproxy20/files/patch-include-common-hathreads.h
new file mode 100644
index 000000000000..eddbc9a6e072
--- /dev/null
+++ b/net/haproxy20/files/patch-include-common-hathreads.h
@@ -0,0 +1,11 @@
+--- include/common/hathreads.h.orig 2018-02-17 18:17:22.219400000 +0000
++++ include/common/hathreads.h 2018-02-17 18:18:44.598422000 +0000
+@@ -104,7 +104,7 @@ extern THREAD_LOCAL unsigned long tid_bit; /* The bit
+ /* TODO: thread: For now, we rely on GCC builtins but it could be a good idea to
+ * have a header file regrouping all functions dealing with threads. */
+
+-#if defined(__GNUC__) && (__GNUC__ < 4 || __GNUC__ == 4 && __GNUC_MINOR__ < 7) && !defined(__clang__)
++#if (defined(__GNUC__) && (__GNUC__ < 4 || __GNUC__ == 4 && __GNUC_MINOR__ < 7) && !defined(__clang__)) || (defined(__clang__) && defined(__i386__))
+ /* gcc < 4.7 */
+
+ #define HA_ATOMIC_ADD(val, i) __sync_add_and_fetch(val, i)