mirror of
https://github.com/czhu12/canine.git
synced 2025-12-17 00:44:33 -06:00
reduce errors on health check
This commit is contained in:
@@ -8,12 +8,17 @@ 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)
|
||||
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
|
||||
service.save
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user