net/haproxy: enable hard stop mode by default, fixes #195

This commit is contained in:
Frank Wall 2017-08-08 00:40:01 +02:00
parent cc6ca832b2
commit 472d5d601e
6 changed files with 31 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -11,6 +11,12 @@
<type>checkbox</type>
<help>Enable or disable the HAProxy service.</help>
</field>
<field>
<id>haproxy.general.gracefulStop</id>
<label>Graceful Stop</label>
<type>checkbox</type>
<help><![CDATA[Enable HAProxy's graceful stop mode. In this mode HAProxy will continue to process existing connections until they close. Note that this may severely slow down HAProxy's shutdown, depending on the configured timeout values. If graceful stop mode is not enabled, HAProxy will use the hard stop mode where it immediately quits and all established connections are closed. Hard stop mode is recommended.]]></help>
</field>
</subtab>
<subtab id="haproxy-general-global" description="Global Parameters">
<field>

View file

@ -9,6 +9,10 @@
<default>0</default>
<Required>Y</Required>
</enabled>
<gracefulStop type="BooleanField">
<default>0</default>
<Required>Y</Required>
</gracefulStop>
<tuning>
<root type="BooleanField">
<default>0</default>

View file

@ -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

View file

@ -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 %}