From b0d602ded1a8155454ce134ec36f86f7dbc805ff Mon Sep 17 00:00:00 2001 From: Johann BERNEZ Date: Sat, 8 Dec 2018 11:03:39 +0100 Subject: [PATCH] Added AUTOHEAL_START_PERIOD to delay the first health check --- README.md | 3 ++- docker-entrypoint | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e2ada63..6aba5dd 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,13 @@ b) Set ENV `AUTOHEAL_CONTAINER_LABEL=all` to watch all running containers. c) Set ENV `AUTOHEAL_CONTAINER_LABEL` to existing label name that has the value `true`. -Note: You must apply `HEALTHCHECK` to your docker images first. See https://docs.docker.com/engine/reference/builder/#/healthcheck for details. +Note: You must apply `HEALTHCHECK` to your docker images first. See https://docs.docker.com/engine/reference/builder/#healthcheck for details. ## ENV Defaults ``` AUTOHEAL_CONTAINER_LABEL=autoheal AUTOHEAL_INTERVAL=5 # check every 5 seconds +AUTOHEAL_START_PERIOD=0 # wait 0 second before first health check DOCKER_SOCK=/var/run/docker.sock ``` diff --git a/docker-entrypoint b/docker-entrypoint index b0921af..bb0b134 100755 --- a/docker-entrypoint +++ b/docker-entrypoint @@ -33,7 +33,9 @@ if [ "$1" = 'autoheal' ] && [ -e ${DOCKER_SOCK} ]; then } fi - echo "Monitoring containers for unhealthy status" + echo "Monitoring containers for unhealthy status in ${AUTOHEAL_START_PERIOD} second(s)" + sleep ${AUTOHEAL_START_PERIOD:=0} + while true; do sleep ${AUTOHEAL_INTERVAL:=5}