Created
March 12, 2023 03:46
-
-
Save rafiramadhana/f9956246ac6e53ebd20a137c4c0f6e8c to your computer and use it in GitHub Desktop.
Wait until MySQL not rungkat
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
#!/bin/sh | |
# Docker-compose check if mysql connection is ready | |
# https://stackoverflow.com/a/51641089 | |
maxcounter=30 | |
counter=1 | |
while ! mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -h"0.0.0.0" -P"3306" -e "SHOW DATABASES;" > /dev/null 2>&1; do | |
sleep 1 | |
counter=`expr $counter + 1` | |
if [ $counter -gt $maxcounter ]; then | |
>&2 echo "Too long waiting for MySQL; failing." | |
exit 1 | |
fi; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment