Skip to content

A platform for community discussion. Free, open, simple.

DEV(cache_critical_dns): improve postgres_healthcheck

Michael Fitz-Payne0553788d3bfa
diff --git a/script/cache_critical_dns b/script/cache_critical_dns
index a4350aed5c3..f63763e5894 100755
--- a/script/cache_critical_dns
+++ b/script/cache_critical_dns
@@ -158,16 +158,18 @@ ensure
end
def postgres_healthcheck(host:, user:, password:, dbname:)
- response = PG::Connection.ping(
+ client = PG::Connection.new(
host: host,
user: user,
password: password,
dbname: dbname,
connect_timeout: 2, # minimum
)
- response == PG::Constants::PQPING_OK
+ client.exec(';').none?
rescue
false
+ensure
+ client.close if client
end
HEALTH_CHECKS = {