Merge pull request #32 from hasnat/patch-3

Do a proper self healthcheck
This commit is contained in:
will Farrell
2019-06-15 18:31:32 -06:00
committed by GitHub
2 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -6,6 +6,6 @@ RUN apk add --no-cache curl jq
COPY docker-entrypoint /
ENTRYPOINT ["/docker-entrypoint"]
HEALTHCHECK --interval=5s CMD exit 0
HEALTHCHECK --interval=5s CMD /docker-entrypoint healthcheck
CMD ["autoheal"]
+7 -1
View File
@@ -12,11 +12,17 @@ term_handler() {
}
docker_curl() {
curl --max-time "${CURL_TIMEOUT}" --no-buffer -s --unix-socket "${DOCKER_SOCK}" "$@"
curl --max-time "${CURL_TIMEOUT}" --no-buffer -s --unix-socket "${DOCKER_SOCK}" "$@" || return 1
return 0
}
trap 'kill ${!}; term_handler' SIGTERM
if [ "$1" = 'healthcheck' ]; then
docker_curl --fail http://localhost/_ping
exit $?
fi
if [ "$1" = 'autoheal' ] && [ -e ${DOCKER_SOCK} ]; then
# https://docs.docker.com/engine/api/v1.25/