From 2f6b001529623e05c1f74a16d50409ca290a52ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Mon, 27 Aug 2018 08:50:20 +0200 Subject: [PATCH] erp5: automatically reload backend apaches when configuration changes Introduce an service to tell apache to reload its config. This uses `hash-files` feature of slapos.cookbook:wrapper to get this process restarted everytime something change in apache configuration files. This service wait forever to prevent reloading apache everytime slapos node instance is running but only when something actually changed. --- stack/erp5/buildout.hash.cfg | 4 ++-- stack/erp5/instance-balancer.cfg.in | 12 ++++++++++++ stack/erp5/instance.cfg.in | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/stack/erp5/buildout.hash.cfg b/stack/erp5/buildout.hash.cfg index 1192f40948..b1aafee92f 100644 --- a/stack/erp5/buildout.hash.cfg +++ b/stack/erp5/buildout.hash.cfg @@ -66,7 +66,7 @@ md5sum = 0969fbb25b05c02ef3c2d437b2f4e1a0 [template] filename = instance.cfg.in -md5sum = be1466bfce26211e1f0b9e5cee47fe44 +md5sum = 0ef032bb7111930c4beb01f2ecd3478a [monitor-template-dummy] filename = dummy.cfg @@ -86,7 +86,7 @@ md5sum = d1257e7e942307be0a79e34aa4320e9f [template-balancer] filename = instance-balancer.cfg.in -md5sum = f0fd49c7d6d9f7c6936afba0d18b7691 +md5sum = c880831c2b941c38417c647f8c01e243 [template-haproxy-cfg] filename = haproxy.cfg.in diff --git a/stack/erp5/instance-balancer.cfg.in b/stack/erp5/instance-balancer.cfg.in index bd869a016f..2769aa60a7 100644 --- a/stack/erp5/instance-balancer.cfg.in +++ b/stack/erp5/instance-balancer.cfg.in @@ -225,6 +225,18 @@ wait-for-files = ${apache-conf-ssl:cert} ${apache-conf-ssl:key} +[{{ section('apache-reload-graceful') }}] +recipe = slapos.cookbook:wrapper +wrapper-path = ${directory:services}/apache-graceful-reload +command-line = + {{ parameter_dict['bash'] }}/bin/bash -c "${apache-graceful:output} && + {{ parameter_dict['coreutils'] }}/bin/sleep infinity" +hash-files = + ${apache-conf-ssl:cert} + ${apache-conf-ssl:key} + ${apache-conf:rendered} + ${apache:wrapper-path} + [apache-graceful] recipe = collective.recipe.template input = inline: diff --git a/stack/erp5/instance.cfg.in b/stack/erp5/instance.cfg.in index 741fec2ed5..792b1a54ce 100644 --- a/stack/erp5/instance.cfg.in +++ b/stack/erp5/instance.cfg.in @@ -56,6 +56,9 @@ openssl-location = {{ openssl_location }} apache = {{ apache_location }} openssl = {{ openssl_location }} haproxy = {{ haproxy_location }} +bash = {{ bash_location }} +coreutils = {{ coreutils_location }} +bin-directory = {{ bin_directory }} apachedex-location = {{ bin_directory }}/apachedex run-apachedex-location = {{ bin_directory }}/runApacheDex promise-check-apachedex-result = {{ bin_directory }}/check-apachedex-result -- 2.30.9