lifecycle: don't use celery ping for worker healthcheck (#5153)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L
2023-04-03 18:15:31 +02:00
committed by GitHub
parent a92786e153
commit 02f75a92ce
2 changed files with 41 additions and 2 deletions

View File

@ -1,5 +1,6 @@
#!/bin/bash -e
MODE_FILE="${TMPDIR}/authentik-mode"
WORKER_HEARTBEAT="${TMPDIR}/authentik-worker"
function log {
printf '{"event": "%s", "level": "info", "logger": "bootstrap"}\n' "$@" > /dev/stderr
@ -80,7 +81,13 @@ elif [[ "$1" == "healthcheck" ]]; then
if [[ $mode == "server" ]]; then
exec curl --user-agent "goauthentik.io lifecycle Healthcheck" -I http://localhost:9000/-/health/ready/
elif [[ $mode == "worker" ]]; then
exec celery -A authentik.root.celery inspect ping -d celery@$HOSTNAME --timeout 5 -j
mtime=$(stat -f %m $WORKER_HEARTBEAT)
time=$(date +"%s")
if [ "$(( $time - $mtime ))" -gt "30" ]; then
log "Worker hasn't updated heartbeat in 30 seconds"
exit 1
fi
exit 0
fi
elif [[ "$1" == "dump_config" ]]; then
exec python -m authentik.lib.config