Merge pull request #94 from g-nardiello/feature-healthcheck

[Feature] Add basic healthcheck
This commit is contained in:
Fco. Javier Delgado del Hoyo 2023-01-20 19:00:55 +01:00 committed by GitHub
commit 19c7f7395d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -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 /HEALTHY.status || exit 1
ENTRYPOINT dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh

View file

@ -13,6 +13,12 @@ docker container run -d \
fradelg/mysql-cron-backup
```
### Healthcheck
Healthcheck is provided as a basic init control.
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

2
run.sh
View file

@ -28,6 +28,8 @@ if [ -n "${EXIT_BACKUP}" ]; then
trap final_backup SIGHUP SIGINT SIGTERM
fi
touch /HEALTHY.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"