From 472d5d601e26f9dd79cc7fa72d7603f89097b631 Mon Sep 17 00:00:00 2001 From: Frank Wall Date: Tue, 8 Aug 2017 00:40:01 +0200 Subject: [PATCH] net/haproxy: enable hard stop mode by default, fixes #195 --- net/haproxy/src/etc/rc.syshook.d/50-haproxy.restart | 7 +++++++ net/haproxy/src/etc/rc.syshook.d/50-haproxy.stop | 7 +++++++ .../mvc/app/controllers/OPNsense/HAProxy/forms/main.xml | 6 ++++++ .../opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml | 4 ++++ .../opnsense/service/conf/actions.d/actions_haproxy.conf | 4 ++-- .../opnsense/service/templates/OPNsense/HAProxy/rc.conf.d | 6 +++++- 6 files changed, 31 insertions(+), 3 deletions(-) create mode 100755 net/haproxy/src/etc/rc.syshook.d/50-haproxy.restart create mode 100755 net/haproxy/src/etc/rc.syshook.d/50-haproxy.stop diff --git a/net/haproxy/src/etc/rc.syshook.d/50-haproxy.restart b/net/haproxy/src/etc/rc.syshook.d/50-haproxy.restart new file mode 100755 index 000000000..2784d4384 --- /dev/null +++ b/net/haproxy/src/etc/rc.syshook.d/50-haproxy.restart @@ -0,0 +1,7 @@ +#!/bin/sh + +. /etc/rc.conf.d/haproxy + +if [ "x${haproxy_hardstop}" == "xYES" ]; then + /usr/local/etc/rc.d/haproxy configtest && /usr/local/etc/rc.d/haproxy hardstop +fi diff --git a/net/haproxy/src/etc/rc.syshook.d/50-haproxy.stop b/net/haproxy/src/etc/rc.syshook.d/50-haproxy.stop new file mode 100755 index 000000000..cac76c6b6 --- /dev/null +++ b/net/haproxy/src/etc/rc.syshook.d/50-haproxy.stop @@ -0,0 +1,7 @@ +#!/bin/sh + +. /etc/rc.conf.d/haproxy + +if [ "x${haproxy_hardstop}" == "xYES" ]; then + /usr/local/etc/rc.d/haproxy hardstop +fi diff --git a/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/forms/main.xml b/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/forms/main.xml index 33aa176c7..66a0b4b57 100644 --- a/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/forms/main.xml +++ b/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/forms/main.xml @@ -11,6 +11,12 @@ checkbox Enable or disable the HAProxy service. + + haproxy.general.gracefulStop + + checkbox + + diff --git a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml index aed80b1e6..dcda4677f 100644 --- a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml +++ b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml @@ -9,6 +9,10 @@ 0 Y + + 0 + Y + 0 diff --git a/net/haproxy/src/opnsense/service/conf/actions.d/actions_haproxy.conf b/net/haproxy/src/opnsense/service/conf/actions.d/actions_haproxy.conf index a40d035d7..c68da0d51 100644 --- a/net/haproxy/src/opnsense/service/conf/actions.d/actions_haproxy.conf +++ b/net/haproxy/src/opnsense/service/conf/actions.d/actions_haproxy.conf @@ -11,13 +11,13 @@ type:script message:starting haproxy [stop] -command:/usr/local/etc/rc.d/haproxy stop; /usr/bin/killall haproxy; exit 0 +command:/usr/local/etc/rc.syshook.d/50-haproxy.stop; /usr/local/etc/rc.d/haproxy stop; /usr/bin/killall haproxy; exit 0 parameters: type:script message:stopping haproxy [restart] -command:/usr/local/opnsense/scripts/OPNsense/HAProxy/setup.sh; /usr/local/etc/rc.d/haproxy restart +command:/usr/local/opnsense/scripts/OPNsense/HAProxy/setup.sh; /usr/local/etc/rc.syshook.d/50-haproxy.restart; /usr/local/etc/rc.d/haproxy restart parameters: type:script message:restarting haproxy diff --git a/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/rc.conf.d b/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/rc.conf.d index 0d4f4b2f1..44eb42162 100644 --- a/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/rc.conf.d +++ b/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/rc.conf.d @@ -3,7 +3,11 @@ haproxy_enable=YES haproxy_opnsense_bootup_run="/usr/local/opnsense/scripts/OPNsense/HAProxy/setup.sh" haproxy_pidfile="/var/run/haproxy.pid" haproxy_config="/usr/local/etc/haproxy.conf" -# haproxy_flags="" +{% if helpers.exists('OPNsense.HAProxy.general.gracefulStop') and OPNsense.HAProxy.general.gracefulStop|default("0") == "1" %} +haproxy_hardstop=NO +{% else %} +haproxy_hardstop=YES +{% endif %} {% else %} haproxy_enable=NO {% endif %}