stale lockfile check

This commit is contained in:
Paolo Asperti 2024-10-15 08:16:57 +02:00
parent 4cb2c5caee
commit 2adcac027b
Signed by: paspo
GPG Key ID: 06D46905D19D5182

View File

@ -31,13 +31,21 @@ else
echo "Info: Healthchecks disabled" echo "Info: Healthchecks disabled"
fi fi
# lockfile check
if [[ -f "${LOCKFILE}" ]] ; then if [[ -f "${LOCKFILE}" ]] ; then
echo "Another instance is still running" | tee -a "${LOGFILE}" # check if stale lockfile
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then if [[ $(pgrep -c btrbk || true) -eq 0 ]] ; then
curl "${CURLOPTS[@]}" --data-binary "@${LOGFILE}" "${HEALTHCHECK_URL}/log" echo "Removing stale lock file: ${LOCKFILE}"
rm "${LOCKFILE}"
else
# another instance is really running, we exit
echo "Another instance is still running" | tee -a "${LOGFILE}"
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
curl "${CURLOPTS[@]}" --data-binary "@${LOGFILE}" "${HEALTHCHECK_URL}/log"
fi
rm -f -- "${LOGFILE}"
exit 0
fi fi
rm -f -- "${LOGFILE}"
exit 0
fi fi
HOST=$(grep -E '^[\ \t]*target[\ \t]+send-receive' /etc/btrbk/btrbk.conf) HOST=$(grep -E '^[\ \t]*target[\ \t]+send-receive' /etc/btrbk/btrbk.conf)