feat: write current process id to all acquired lock files

This allows us to check on what process created a lock.

Additionally, we now always have a DOKKU_PID value, even when running in cron (which does not have access to BASH_PID.
This commit is contained in:
Jose Diaz-Gonzalez
2024-03-14 05:54:37 -04:00
parent 5553da1be1
commit 83b89453a5
3 changed files with 3 additions and 2 deletions

4
dokku
View File

@@ -55,7 +55,7 @@ export DOKKU_SYSTEM_USER=${DOKKU_SYSTEM_USER:="dokku"}
export DOKKU_API_VERSION=1
export DOKKU_NOT_IMPLEMENTED_EXIT=10
export DOKKU_VALID_EXIT=0
export DOKKU_PID="$BASHPID"
export DOKKU_PID="${DOKKU_PID:=$$}"
export DOKKU_LOGS_DIR=${DOKKU_LOGS_DIR:="/var/log/dokku"}
export DOKKU_LOGS_HOST_DIR=${DOKKU_LOGS_HOST_DIR:=$DOKKU_LOGS_DIR}
@@ -88,7 +88,7 @@ fi
! has_tty && DOKKU_QUIET_OUTPUT=1
if [[ $(id -un) != "dokku" ]]; then
unset TMP TMPDIR TEMP TEMPDIR
unset DOKKU_PID TMP TMPDIR TEMP TEMPDIR
if [[ ! $1 =~ plugin:* ]] && [[ $1 != "ssh-keys:add" ]] && [[ $1 != "ssh-keys:remove" ]] && [[ $1 != "scheduler-k3s:initialize" ]] && [[ $1 != "scheduler-k3s:uninstall" ]]; then
export SSH_USER=$(id -un)
sudo -u dokku -E -H "$0" "$@"

View File

@@ -983,6 +983,7 @@ acquire_advisory_lock() {
dokku_log_fail "Run 'apps:unlock' to release the existing deploy lock"
fi
fi
echo "$DOKKU_PID" >"$LOCK_FILE"
}
release_advisory_lock() {

Binary file not shown.