github.com/ddev/ddev@v1.23.2-0.20240519125000-d824ffe36ff3/containers/ddev-traefik-router/traefik_healthcheck.sh (about) 1 #!/bin/bash 2 3 ## traefik health check 4 set -eu -o pipefail 5 sleeptime=59 6 7 # Since docker doesn't provide a lazy period for startup, 8 # we track health. If the last check showed healthy 9 # as determined by existence of /tmp/healthy, then 10 # sleep at startup. This requires the timeout to be set 11 # higher than the sleeptime used here. 12 if [ -f /tmp/healthy ]; then 13 printf "container was previously healthy, so sleeping ${sleeptime} seconds before continuing healthcheck... " 14 sleep ${sleeptime} 15 fi 16 17 # If /tmp/initializing, it means we're loading the default starter database 18 if [ -f /tmp/initializing ]; then 19 printf "initializing" 20 exit 1 21 fi 22 23 # If we can now access the traefik ping endpoint, then we're healthy 24 # We should be able to use `traefik healthcheck --ping` but it doesn't work if 25 # using nonstandard port (always tries port 8080 even if traefik port is something else) 26 if curl -s -f http://127.0.0.1:${TRAEFIK_MONITOR_PORT}/ping ; then 27 printf "healthy" 28 touch /tmp/healthy 29 exit 0 30 fi 31 32 rm -f /tmp/healthy 33 exit 1 34