Skip to content

Commit 19c7f73

Browse files
authored
Merge pull request #94 from g-nardiello/feature-healthcheck
[Feature] Add basic healthcheck
2 parents 37334bf + 25729c7 commit 19c7f73

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ RUN mkdir /backup && \
4141

4242
VOLUME ["/backup"]
4343

44-
CMD dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh
44+
HEALTHCHECK --interval=2s --retries=1800 \
45+
CMD stat /HEALTHY.status || exit 1
46+
47+
ENTRYPOINT dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ docker container run -d \
1313
fradelg/mysql-cron-backup
1414
```
1515

16+
### Healthcheck
17+
18+
19+
Healthcheck is provided as a basic init control.
20+
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.
21+
1622
## Variables
1723

1824

run.sh

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ if [ -n "${EXIT_BACKUP}" ]; then
2828
trap final_backup SIGHUP SIGINT SIGTERM
2929
fi
3030

31+
touch /HEALTHY.status
32+
3133
echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf
3234
crontab /tmp/crontab.conf
3335
echo "=> Running cron task manager in foreground"

0 commit comments

Comments
 (0)