Skip to content

Commit

Permalink
Merge pull request #422 from bento-platform/chore/improve-wait-for-db
Browse files Browse the repository at this point in the history
chore: more logging from wait_for_db script
  • Loading branch information
davidlougheed committed Jul 27, 2023
2 parents 796ba5e + a8be92d commit e454c55
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions wait_for_db.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@ if [[ -n "${POSTGRES_PASSWORD_FILE}" ]]; then
fi
export PGPASSWORD

# Check if we have a 0-length password; if so, output a warning
if [[ -z "${PGPASSWORD}" ]]; then
>&2 echo "Warning: 0-length POSTGRES_PASSWORD. Make sure POSTGRES_PASSWORD / BENTOV2_KATSU_DB_PASSWORD is set!"
fi

# Set default values for Postgres connection variables
: "${POSTGRES_DATABASE:=metadata}"
: "${POSTGRES_HOST:=localhost}"
: "${POSTGRES_PORT:=5432}"
: "${POSTGRES_USER:=admin}"

until \
echo "Checking for Postgres on postgresql://${POSTGRES_USER}:[redacted]@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}"
pg_isready \
-d "${POSTGRES_DATABASE:-metadata}" \
-h "${POSTGRES_HOST:-localhost}" \
-p "${POSTGRES_PORT:-5432}" \
-U "${POSTGRES_USER:-admin}"
-d "${POSTGRES_DATABASE}" \
-h "${POSTGRES_HOST}" \
-p "${POSTGRES_PORT}" \
-U "${POSTGRES_USER}"
do
echo "Waiting 2 seconds for database host..."
sleep 2
Expand Down

0 comments on commit e454c55

Please sign in to comment.