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 <andrea.cirulli@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Kyle Rosenbaum <krosenbaum@instructure.com>
Product-Review: Kyle Rosenbaum <krosenbaum@instructure.com>
This commit is contained in:
Kyle Rosenbaum 2020-10-29 14:18:25 -07:00
parent 048ec11b63
commit d123b00089
1 changed files with 6 additions and 3 deletions

View File

@ -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