diff --git a/plugins/haproxy-vhosts/command-functions b/plugins/haproxy-vhosts/command-functions index 1854569b7..648165602 100755 --- a/plugins/haproxy-vhosts/command-functions +++ b/plugins/haproxy-vhosts/command-functions @@ -129,6 +129,7 @@ cmd-haproxy-start() { local TMP_COMPOSE_FILE=$(mktemp "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX") trap "rm -rf '$TMP_COMPOSE_FILE' >/dev/null" RETURN INT TERM EXIT + fn-plugin-property-write "caddy" "--global" "proxy-status" "started" fn-haproxy-template-compose-file "$TMP_COMPOSE_FILE" "$DOCKER_BIN" compose -f "$TMP_COMPOSE_FILE" -p haproxy up -d --quiet-pull } @@ -145,6 +146,7 @@ cmd-haproxy-stop() { local TMP_COMPOSE_FILE=$(mktemp "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX") trap "rm -rf '$TMP_COMPOSE_FILE' >/dev/null" RETURN INT TERM EXIT + fn-plugin-property-write "haproxy" "--global" "proxy-status" "stopped" fn-haproxy-template-compose-file "$TMP_COMPOSE_FILE" "$DOCKER_BIN" compose -f "$TMP_COMPOSE_FILE" -p haproxy down --remove-orphans } diff --git a/plugins/haproxy-vhosts/pre-restore b/plugins/haproxy-vhosts/pre-restore new file mode 100755 index 000000000..8e3086210 --- /dev/null +++ b/plugins/haproxy-vhosts/pre-restore @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/haproxy-vhosts/command-functions" +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +trigger-haproxy-pre-restore() { + declare desc="pre-restore the caddy proxy" + declare trigger="install" + + if [[ "$(fn-plugin-property-get "haproxy" "--global" "proxy-status")" == "stopped" ]]; then + return + fi + + if ! cmd-haproxy-start; then + dokku_log_warn "Failed to restore haproxy proxy, requests may not route as expected" + fi +} + +trigger-haproxy-pre-restore "$@"