fix: do not start nginx if there are no apps with nginx as a proxy
Also start it by default in the case where there are no apps at all, as that likely means this is a first-time installation.
This commit is contained in:
@@ -156,9 +156,31 @@ trigger-nginx-vhosts-install() {
|
|||||||
# avoid failing runit init calls on install
|
# avoid failing runit init calls on install
|
||||||
# the runit binaries are not yet available during dockerfile building
|
# the runit binaries are not yet available during dockerfile building
|
||||||
# and therefore both these calls will fail
|
# and therefore both these calls will fail
|
||||||
if [[ ! -x /usr/bin/sv ]] && [[ "$(fn-plugin-property-get "nginx" "--global" "proxy-status")" != "stopped" ]]; then
|
if [[ -x /usr/bin/sv ]]; then
|
||||||
fn-nginx-vhosts-nginx-init-cmd start || fn-nginx-vhosts-nginx-init-cmd reload
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# avoid starting nginx if it was stopped via the nginx:stop command
|
||||||
|
if [[ "$(fn-plugin-property-get "nginx" "--global" "proxy-status")" == "stopped" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# only start nginx if there is an app with the nginx proxy type
|
||||||
|
local start_nginx=false
|
||||||
|
local has_apps=false
|
||||||
|
for app in $(dokku_apps "false" 2>/dev/null); do
|
||||||
|
has_apps=true
|
||||||
|
if [[ "$(plugn trigger proxy-type "$app")" == "nginx" ]]; then
|
||||||
|
start_nginx=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$start_nginx" == "false" ]] && [[ "$has_apps" == "true" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
fn-nginx-vhosts-nginx-init-cmd start || fn-nginx-vhosts-nginx-init-cmd reload
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger-nginx-vhosts-install "$@"
|
trigger-nginx-vhosts-install "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user