From d123b00089ca4aa32a8f61bf2a657342840868b2 Mon Sep 17 00:00:00 2001 From: Kyle Rosenbaum Date: Thu, 29 Oct 2020 14:18:25 -0700 Subject: [PATCH] add timeout parameter to wait-for-it script; refs DE-347 this parameter is added for easier testing of postgres spin up timeouts. flag=none test plan: * wait-for-it still behaves as expected and defaults to 60 seconds. Change-Id: Iec8c704f68bf36941ffea043ed5c942b3e70d758 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251499 Reviewed-by: Andrea Cirulli Tested-by: Service Cloud Jenkins QA-Review: Kyle Rosenbaum Product-Review: Kyle Rosenbaum --- docker-compose/postgres/wait-for-it | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docker-compose/postgres/wait-for-it b/docker-compose/postgres/wait-for-it index 73b3174fa9a..a6e0b2d2be4 100755 --- a/docker-compose/postgres/wait-for-it +++ b/docker-compose/postgres/wait-for-it @@ -3,10 +3,13 @@ set -x ip_address=$(hostname -i) -echo Attempting connection to postgres... -for _ in {1..60}; do +timeout=${1:-60} + +echo Attempting connection to Postgres for $timeout seconds... +for _ in $(seq 1 $timeout); do gosu postgres pg_isready --host="$ip_address" && echo "Postgres connected!" && exit sleep 1 done -echo Postgres is still down after 60 seconds. + +echo Postgres is still down after $timeout seconds. exit 1