diff --git a/plugins/nginx-vhosts/command-functions b/plugins/nginx-vhosts/command-functions index a2de9beaf..5efbd339c 100755 --- a/plugins/nginx-vhosts/command-functions +++ b/plugins/nginx-vhosts/command-functions @@ -235,6 +235,29 @@ cmd-nginx-stop() { fn-nginx-vhosts-nginx-init-cmd "disable" } +cmd-nginx-reload() { + declare desc="reloads the nginx server config" + declare cmd="nginx:reload" + [[ "$1" == "$cmd" ]] && shift 1 + + local NGINX_LOCATION EXIT_CODE + NGINX_LOCATION=$(get_nginx_location) + if [[ -z "$NGINX_LOCATION" ]]; then + exit 1 + fi + + set +e + sudo "$NGINX_LOCATION" -t &>/dev/null + EXIT_CODE=$? + set -e + if [[ "$EXIT_CODE" -ne "0" ]]; then + sudo "$NGINX_LOCATION" -t + exit "$EXIT_CODE" + fi + + fn-nginx-vhosts-nginx-init-cmd "reload" +} + cmd-nginx-validate-config() { declare desc="validates and optionally cleans up invalid nginx configurations" declare cmd="nginx:validate-config" diff --git a/plugins/nginx-vhosts/help-functions b/plugins/nginx-vhosts/help-functions index 53219a912..9286119be 100755 --- a/plugins/nginx-vhosts/help-functions +++ b/plugins/nginx-vhosts/help-functions @@ -32,6 +32,7 @@ fn-help-content() { nginx:report [] [], Displays an nginx report for one or more apps nginx:set (), Set or clear an nginx property for an app nginx:show-config , Display app nginx config + nginx:reload, Reloads the nginx server config nginx:start, Starts the nginx server nginx:stop, Stops the nginx server nginx:validate-config [] [--clean], Validates and optionally cleans up invalid nginx configurations diff --git a/plugins/nginx-vhosts/subcommands/reload b/plugins/nginx-vhosts/subcommands/reload new file mode 100755 index 000000000..62edc03a2 --- /dev/null +++ b/plugins/nginx-vhosts/subcommands/reload @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/command-functions" +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +cmd-nginx-reload "$@"