Merge pull request #449 from CanineHQ/chrishzu__reduce_errors

reduce errors on health check
This commit is contained in:
Chris Zhu
2025-12-12 02:34:53 +09:00
committed by GitHub

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