Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: more logging from wait_for_db script #422

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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