timeout 40s /bin/bash -c "while ! httping -qc1 http://somehost:8080/app ; do sleep 1 ; done; echo OK" || echo TIMEOUT If the service cannot be reached within 40s then TIMEOUT will be printed otherwise OK.
Very cool!
If one instead wants to use
curl
to check the HTTP status code, then the git could be adapted to: