fix: check if nginx is running before reloading during an app deletion

The purpose of the reload is to remove nginx from being loaded. If nginx isn't running, then by definition the config is not loaded.

Closes #6832
This commit is contained in:
Jose Diaz-Gonzalez
2024-09-23 21:21:33 -04:00
parent 0f8395365e
commit ac56a5ffdd
3 changed files with 59 additions and 6 deletions

View File

@@ -523,6 +523,57 @@ fn-nginx-vhosts-nginx-location() {
echo "$NGINX_LOCATION"
}
fn-nginx-vhosts-nginx-is-running() {
declare desc="check if nginx is running"
local NGINX_INIT_NAME
NGINX_INIT_NAME=nginx
if fn-nginx-vhosts-uses-openresty; then
NGINX_INIT_NAME=openresty
fi
case "$DOKKU_DISTRO" in
debian | raspbian)
if [[ -x "$systemctl_path" ]]; then
if sudo "$systemctl_path" is-active --quiet "$NGINX_INIT_NAME"; then
return 0
fi
else
dokku_log_warn "Checking $NGINX_INIT_NAME status is not possible for init.d managed services"
return 0
fi
;;
ubuntu)
# support docker-based installations
if [[ "$DOKKU_INIT_SYSTEM" == "sv" ]]; then
if sudo /usr/bin/sv status $NGINX_INIT_NAME | grep -q "^run:"; then
return 0
fi
elif [[ -x "$systemctl_path" ]]; then
if sudo "$systemctl_path" is-active --quiet "$NGINX_INIT_NAME"; then
return 0
fi
elif [[ -x /usr/bin/sv ]]; then
if sudo /usr/bin/sv status $NGINX_INIT_NAME | grep -q "^run:"; then
return 0
fi
else
dokku_log_warn "Checking $NGINX_INIT_NAME status is not possible for init.d managed services"
return 0
fi
;;
arch)
if sudo "$systemctl_path" is-active --quiet "$NGINX_INIT_NAME"; then
return 0
fi
;;
esac
return 1
}
fn-nginx-vhosts-nginx-init-cmd() {
declare desc="start nginx for given distros"
declare CMD="$1"