mirror of
https://github.com/willfarrell/docker-autoheal.git
synced 2024-12-06 19:16:20 +01:00
Merge pull request #32 from hasnat/patch-3
Do a proper self healthcheck
This commit is contained in:
+1
-1
@@ -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
@@ -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/
|
||||
|
||||
Reference in New Issue
Block a user