reduce errors on health check

This commit is contained in:
Chris
2025-12-11 09:30:58 -08:00
parent 15aad3ef26
commit 53154d1571

View File

@@ -8,10 +8,15 @@ class Scheduled::CheckHealthJob < ApplicationJob
if service.domains.any?
url = File.join("https://#{service.domains.first.domain_name}", service.healthcheck_url)
Rails.logger.info("Checking health for #{service.name} at #{url}")
response = HTTParty.get(url)
if response.success?
service.status = :healthy
else
begin
response = HTTParty.get(url, timeout: 10)
if response.success?
service.status = :healthy
else
service.status = :unhealthy
end
rescue Net::OpenTimeout, Net::ReadTimeout, Errno::ECONNREFUSED, SocketError, HTTParty::Error => e
Rails.logger.warn("Health check failed for #{service.name}: #{e.class} - #{e.message}")
service.status = :unhealthy
end
service.last_health_checked_at = DateTime.current