-
-
Save henri/3a25aa3e3519863b27dc4e14dd27efee to your computer and use it in GitHub Desktop.
Script to wait for localhost service in bash, with retries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
TRIES=0 | |
until [ $TRIES -eq 10 ] || nc -z localhost 3000; do | |
sleep 0.1 | |
TRIES=$(( TRIES+1 )) | |
done | |
if [[ $TRIES -gt 9 ]] | |
then | |
echo "Failed to connect to container..." | |
exit 999 | |
else | |
echo "Container started!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment