From: Andrew Donnellan Date: Thu, 25 May 2017 05:36:18 +0000 (+1000) Subject: docker: increase database connection timeout X-Git-Tag: v2.0.0-rc3~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d63531789955f5c4dec2c0c0899485b79fdcb96;p=thirdparty%2Fpatchwork.git docker: increase database connection timeout When starting the Docker environment, if the web container can't see the database immediately, it waits 5 seconds, tries again, then waits 15 seconds more to account for first-time start-ups where it takes a bit longer for the database to be initialised. Some of us, unfortunately, have slow computers with slow mechanical hard drives which take just a bit longer. Increase the second timeout from 15 seconds to 60 seconds, testing every 5 seconds. Signed-off-by: Andrew Donnellan Acked-by: Daniel Axtens Reviewed-by: Stephen Finucane --- diff --git a/tools/docker/entrypoint.sh b/tools/docker/entrypoint.sh index 5a23fa36..949d8afd 100755 --- a/tools/docker/entrypoint.sh +++ b/tools/docker/entrypoint.sh @@ -53,8 +53,13 @@ if ! test_db_connection; then sleep 5 if ! test_db_connection; then echo "Still cannot connect to MySQL." - echo "Maybe you are starting the db for the first time. Waiting 15 seconds." - sleep 15 + echo "Maybe you are starting the db for the first time. Waiting up to 60 seconds." + for i in {0..9}; do + sleep 5 + if test_db_connection; then + break + fi + done if ! test_db_connection; then echo "Still cannot connect to MySQL. Giving up." echo "Are you using docker-compose? If not, have you set up the link correctly?"