From 39d39915e464041792909d4c1d590f7cf45366d3 Mon Sep 17 00:00:00 2001 From: "g.nardiello" Date: Thu, 5 Jan 2023 11:55:04 +0100 Subject: [PATCH 1/5] Added file-based HEALTHCHECK --- Dockerfile | 5 ++++- run.sh | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c06ccf7..fdfa250 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,4 +41,7 @@ RUN mkdir /backup && \ VOLUME ["/backup"] -CMD dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh +HEALTHCHECK --interval=2s --retries=1800 \ + CMD stat /HEALTLY.status || exit 1 + +ENTRYPOINT dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh \ No newline at end of file diff --git a/run.sh b/run.sh index 95f8009..862a566 100755 --- a/run.sh +++ b/run.sh @@ -14,6 +14,8 @@ elif [ -n "${INIT_RESTORE_LATEST}" ]; then find /backup -maxdepth 1 -name '*.sql.gz' | tail -1 | xargs /restore.sh fi +touch /HEALTLY.status + echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf crontab /tmp/crontab.conf echo "=> Running cron task manager in foreground" From f8307fd40f7e54a870d9e518169be1abdb118f1a Mon Sep 17 00:00:00 2001 From: "g.nardiello" Date: Fri, 6 Jan 2023 08:43:40 +0100 Subject: [PATCH 2/5] Improved docs for Healthcheck --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 923ec5e..8d3a2dd 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,12 @@ docker container run -d \ fradelg/mysql-cron-backup ``` +### Healthcheck + + +Healthcheck is provided as a basic init control. +Container is **Healthly** after the database init phase, that is after `INIT_BACKUP` or `INIT_RESTORE_LATEST` happends without check if there is an error, **Starting** otherwise. Not other checks are actually provided. + ## Variables From 81f5e3dc69f8cc7e5dd390b98a7cedeabb8efb5b Mon Sep 17 00:00:00 2001 From: Giuseppe Nardiello Date: Tue, 10 Jan 2023 23:55:38 +0100 Subject: [PATCH 3/5] Corrected *Healthy* typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d3a2dd..b4d98fb 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ docker container run -d \ Healthcheck is provided as a basic init control. -Container is **Healthly** after the database init phase, that is after `INIT_BACKUP` or `INIT_RESTORE_LATEST` happends without check if there is an error, **Starting** otherwise. Not other checks are actually provided. +Container is **Healthy** after the database init phase, that is after `INIT_BACKUP` or `INIT_RESTORE_LATEST` happends without check if there is an error, **Starting** otherwise. Not other checks are actually provided. ## Variables From 96ca5bb74ae3785e39ee9ca529d05436c30ae582 Mon Sep 17 00:00:00 2001 From: Giuseppe Nardiello Date: Fri, 20 Jan 2023 12:04:19 +0100 Subject: [PATCH 4/5] Corrected HEALTHY.status typo --- Dockerfile | 2 +- run.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fdfa250..ad9ed2b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,6 @@ RUN mkdir /backup && \ VOLUME ["/backup"] HEALTHCHECK --interval=2s --retries=1800 \ - CMD stat /HEALTLY.status || exit 1 + CMD stat /HEALTHY.status || exit 1 ENTRYPOINT dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh \ No newline at end of file diff --git a/run.sh b/run.sh index 862a566..79e05ab 100755 --- a/run.sh +++ b/run.sh @@ -14,7 +14,7 @@ elif [ -n "${INIT_RESTORE_LATEST}" ]; then find /backup -maxdepth 1 -name '*.sql.gz' | tail -1 | xargs /restore.sh fi -touch /HEALTLY.status +touch /.status echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf crontab /tmp/crontab.conf From 25729c7bc374664d75dbbb7b2c1aa4cc5166e18f Mon Sep 17 00:00:00 2001 From: Giuseppe Nardiello Date: Fri, 20 Jan 2023 12:04:42 +0100 Subject: [PATCH 5/5] Corrected HEALTHY.status typo --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 79e05ab..e2cb596 100755 --- a/run.sh +++ b/run.sh @@ -14,7 +14,7 @@ elif [ -n "${INIT_RESTORE_LATEST}" ]; then find /backup -maxdepth 1 -name '*.sql.gz' | tail -1 | xargs /restore.sh fi -touch /.status +touch /HEALTHY.status echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf crontab /tmp/crontab.conf