Skip to content

Commit

Permalink
Merge pull request #94 from g-nardiello/feature-healthcheck
Browse files Browse the repository at this point in the history
[Feature] Add basic healthcheck
  • Loading branch information
fradelg authored Jan 20, 2023
2 parents 37334bf + 25729c7 commit 19c7f73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 2 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 19c7f73

Please sign in to comment.