github.com/drud/ddev@v1.21.5-alpha1.0.20230226034409-94fcc4b94453/containers/ddev-webserver/ddev-webserver-base-scripts/healthcheck.sh (about) 1 #!/bin/sh 2 3 # This uses /bin/sh so it doesn't initialize profile/bashrc/etc 4 5 # ddev-webserver healthcheck 6 7 set -e 8 9 sleeptime=59 10 11 # Make sure that both phpstatus, mounted code, and mailhog 12 # are working. 13 # Since docker doesn't provide a lazy period for startup, 14 # we track health. If the last check showed healthy 15 # as determined by existence of /tmp/healthy, then 16 # sleep at startup. This requires the timeout to be set 17 # higher than the sleeptime used here. 18 if [ -f /tmp/healthy ]; then 19 printf "container was previously healthy, so sleeping ${sleeptime} seconds before continuing healthcheck... " 20 sleep ${sleeptime} 21 fi 22 23 phpstatus="false" 24 htmlaccess="false" 25 mailhog="false" 26 if curl --fail -s 127.0.0.1/phpstatus >/dev/null ; then 27 phpstatus="true" 28 printf "phpstatus: OK " 29 else 30 printf "phpstatus: FAILED " 31 fi 32 33 if ls /var/www/html >/dev/null; then 34 htmlaccess="true" 35 printf "/var/www/html: OK " 36 else 37 printf "/var/www/html: FAILED" 38 fi 39 40 if curl --fail -s 127.0.0.1:8025 >/dev/null; then 41 mailhog="true" 42 printf "mailhog: OK " ; 43 else 44 printf "mailhog: FAILED " 45 fi 46 47 if [ "${phpstatus}" = "true" ] && [ "${htmlaccess}" = "true" ] && [ "${mailhog}" = "true" ] ; then 48 touch /tmp/healthy 49 exit 0 50 fi 51 rm -f /tmp/healthy 52 exit 1 53 54