From c209787de891985ac4c9ee6eb2079a600f91a811 Mon Sep 17 00:00:00 2001 From: fomojola Date: Thu, 30 Dec 2021 22:49:57 -0500 Subject: [PATCH 1/3] Conditionally restart NGINX Before restarting nginx, check if the current app is using a proxy and if the selected proxy is in fact NGINX. Only then should we bother invoking the nginx reload. Fixes https://github.com/dokku/dokku/issues/4987 --- plugins/nginx-vhosts/functions | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/nginx-vhosts/functions b/plugins/nginx-vhosts/functions index fa4f963c3..5654bc315 100755 --- a/plugins/nginx-vhosts/functions +++ b/plugins/nginx-vhosts/functions @@ -128,7 +128,13 @@ validate_nginx() { restart_nginx() { declare desc="restart nginx for given distros" - fn-nginx-vhosts-nginx-init-cmd "reload" + local PROXY_ENABLED="$(plugn trigger proxy-is-enabled "$APP")" + local PROXY_TYPE="$(plugn trigger proxy-type "$APP")" + if [[ "$PROXY_ENABLED" == "true" ]]; then + if [[ "$PROXY_TYPE" == "nginx" ]]; then + fn-nginx-vhosts-nginx-init-cmd "reload" + fi + fi } nginx_logs() { From 55d8e2db81f2e9b7dac8f881e66c1d07fd3cf02c Mon Sep 17 00:00:00 2001 From: fomojola Date: Thu, 30 Dec 2021 22:56:47 -0500 Subject: [PATCH 2/3] Formatting fixes --- plugins/nginx-vhosts/functions | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/nginx-vhosts/functions b/plugins/nginx-vhosts/functions index 5654bc315..ad6755672 100755 --- a/plugins/nginx-vhosts/functions +++ b/plugins/nginx-vhosts/functions @@ -130,10 +130,8 @@ restart_nginx() { declare desc="restart nginx for given distros" local PROXY_ENABLED="$(plugn trigger proxy-is-enabled "$APP")" local PROXY_TYPE="$(plugn trigger proxy-type "$APP")" - if [[ "$PROXY_ENABLED" == "true" ]]; then - if [[ "$PROXY_TYPE" == "nginx" ]]; then - fn-nginx-vhosts-nginx-init-cmd "reload" - fi + if [[ "$PROXY_ENABLED" == "true" ]] && [[ "$PROXY_TYPE" == "nginx" ]]; then + fn-nginx-vhosts-nginx-init-cmd "reload" fi } From c75fe998e25e7ac4a35c7b98f03ccc9cd6fa0021 Mon Sep 17 00:00:00 2001 From: Femi Omojola Date: Fri, 31 Dec 2021 00:48:47 -0500 Subject: [PATCH 3/3] shfmt fixes --- plugins/nginx-vhosts/functions | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/nginx-vhosts/functions b/plugins/nginx-vhosts/functions index ad6755672..1abe7ae1f 100755 --- a/plugins/nginx-vhosts/functions +++ b/plugins/nginx-vhosts/functions @@ -128,10 +128,10 @@ validate_nginx() { restart_nginx() { declare desc="restart nginx for given distros" - local PROXY_ENABLED="$(plugn trigger proxy-is-enabled "$APP")" - local PROXY_TYPE="$(plugn trigger proxy-type "$APP")" + local PROXY_ENABLED="$(plugn trigger proxy-is-enabled "$APP")" + local PROXY_TYPE="$(plugn trigger proxy-type "$APP")" if [[ "$PROXY_ENABLED" == "true" ]] && [[ "$PROXY_TYPE" == "nginx" ]]; then - fn-nginx-vhosts-nginx-init-cmd "reload" + fn-nginx-vhosts-nginx-init-cmd "reload" fi }