refactor: use the properties system instead of the data dir for tracking whether a proxy should be stopped or started

This commit is contained in:
Jose Diaz-Gonzalez
2022-11-22 23:29:34 -05:00
parent 6fed37b408
commit 5fed0c45ac
7 changed files with 15 additions and 16 deletions

View File

@@ -115,8 +115,7 @@ cmd-nginx-start() {
declare cmd="nginx:start"
[[ "$1" == "$cmd" ]] && shift 1
touch "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.started"
rm -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.stopped"
fn-plugin-property-write "nginx" "--global" "proxy-status" "started"
fn-nginx-vhosts-nginx-init-cmd "enable"
fn-nginx-vhosts-nginx-init-cmd "start"
}
@@ -126,8 +125,7 @@ cmd-nginx-stop() {
declare cmd="nginx:stop"
[[ "$1" == "$cmd" ]] && shift 1
rm -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.started"
touch "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.stopped"
fn-plugin-property-write "nginx" "--global" "proxy-status" "stopped"
fn-nginx-vhosts-nginx-init-cmd "stop"
fn-nginx-vhosts-nginx-init-cmd "disable"
}

View File

@@ -130,10 +130,15 @@ trigger-nginx-vhosts-install() {
fn-nginx-vhosts-migrate-env-vars
fn-nginx-vhosts-migrate-nginx-conf-sigil
if [[ -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.stopped" ]]; then
rm -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.stopped"
fn-plugin-property-write "nginx" "--global" "proxy-status" "stopped"
fi
# avoid failing runit init calls on install
# the runit binaries are not yet available during dockerfile building
# and therefore both these calls will fail
if [[ ! -x /usr/bin/sv ]] && [[ ! -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.stopped" ]]; then
if [[ ! -x /usr/bin/sv ]] && [[ "$(fn-plugin-property-get "nginx" "--global" "proxy-status")" != "stopped" ]]; then
fn-nginx-vhosts-nginx-init-cmd start || fn-nginx-vhosts-nginx-init-cmd reload
fi
}

View File

@@ -8,7 +8,7 @@ trigger-nginx-pre-restore() {
declare desc="pre-restore the nginx proxy"
declare trigger="install"
if [[ ! -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.started" ]]; then
if [[ "$(fn-plugin-property-get "nginx" "--global" "proxy-status")" == "stopped" ]]; then
return
fi