Add more debug diags

This commit is contained in:
Colin Seymour
2026-06-15 15:31:18 +00:00
parent a7bc113eb0
commit 64033b692e
2 changed files with 24 additions and 8 deletions
@@ -64,6 +64,13 @@ until pg_isready -h "$DATABASE_HOST" -p "$DATABASE_PORT" > /dev/null 2>&1; do
pg_wait_attempt=$((pg_wait_attempt + 1))
if [[ "$pg_wait_attempt" -ge "$pg_wait_max" ]]; then
bashio::log.error "PostgreSQL at '$DATABASE_HOST' is not ready or unreachable after $((pg_wait_max * 2))s"
# Distinguish a DNS/networking problem from a database that is simply down,
# so the failure is actionable: resolve the host and report what we find.
if getent hosts "$DATABASE_HOST" > /dev/null 2>&1; then
bashio::log.error "Host '$DATABASE_HOST' resolves to $(getent hosts "$DATABASE_HOST" | awk '{print $1}' | tr '\n' ' ')but is not accepting connections on port $DATABASE_PORT - is the PostgreSQL add-on running and healthy?"
else
bashio::log.error "Host '$DATABASE_HOST' does not resolve - the PostgreSQL add-on may be stopped or on a different network"
fi
exit 1
fi
bashio::log.info "PostgreSQL not ready yet, retrying in 2s (${pg_wait_attempt}/${pg_wait_max})..."