lifecycle: optimise container lifecycle and process signals (#3332)

* add dumb-init, use exec in wrapper

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* fix exec?

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens L
2022-07-30 22:41:29 +02:00
committed by GitHub
parent d4b8dd7fcc
commit db1dd196e0
4 changed files with 27 additions and 9 deletions

View File

@ -29,7 +29,7 @@ function check_if_root {
fi
# Fix permissions of backups and media
chown -R authentik:authentik /media /certs
chpst -u authentik:$GROUP env HOME=/authentik $1
exec chpst -u authentik:$GROUP env HOME=/authentik $1
}
MODE_FILE="/tmp/authentik-mode"
@ -41,7 +41,7 @@ if [[ "$1" == "server" ]]; then
if [[ ! -z "${AUTHENTIK_BOOTSTRAP_PASSWORD}" || ! -z "${AUTHENTIK_BOOTSTRAP_TOKEN}" ]]; then
python -m manage bootstrap_tasks
fi
/authentik-proxy
exec /authentik-proxy
elif [[ "$1" == "worker" ]]; then
wait_for_db
echo "worker" > $MODE_FILE
@ -56,12 +56,14 @@ elif [[ "$1" == "test" ]]; then
elif [[ "$1" == "healthcheck" ]]; then
mode=$(cat $MODE_FILE)
if [[ $mode == "server" ]]; then
curl --user-agent "goauthentik.io lifecycle Healthcheck" -I http://localhost:9000/-/health/ready/
exec curl --user-agent "goauthentik.io lifecycle Healthcheck" -I http://localhost:9000/-/health/ready/
elif [[ $mode == "worker" ]]; then
celery -A authentik.root.celery inspect ping -d celery@$HOSTNAME --timeout 5 -j
exec celery -A authentik.root.celery inspect ping -d celery@$HOSTNAME --timeout 5 -j
fi
elif [[ "$1" == "dump_config" ]]; then
python -m authentik.lib.config
exec python -m authentik.lib.config
elif [[ "$1" == "debug" ]]; then
exec sleep infinity
else
python -m manage "$@"
exec python -m manage "$@"
fi