From 14fef26e20375323cfc1015a58d23f69dc18e386 Mon Sep 17 00:00:00 2001 From: William Lachance Date: Tue, 2 Apr 2019 16:09:00 -0400 Subject: [PATCH] Fix wait for db/redis code --- Dockerfile | 2 +- bin/run | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3ee4e5e..2f05873 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ RUN mkdir -p \ /usr/share/man/man8 && \ apt-get update && \ apt-get install -y --no-install-recommends build-essential libpq-dev \ - mime-support postgresql-client gettext curl && \ + mime-support postgresql-client gettext curl netcat && \ apt-get autoremove -y && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/bin/run b/bin/run index 09b81e9..167ce74 100755 --- a/bin/run +++ b/bin/run @@ -16,11 +16,9 @@ usage() { wait_for() { tries=0 echo "Waiting for $1 to listen on $2..." - while true; do - [[ $tries -lt $TRIES ]] || return - (echo > /dev/tcp/$1/$2) >/dev/null 2>&1 - result= + until nc -z $1 $2; do [[ $? -eq 0 ]] && return + [[ $tries -lt $TRIES ]] || (echo "Timed out!" && exit 1) sleep $SLEEP tries=$((tries + 1)) done