Sha256: 38700b1c15b8a76f59cade1a496638317d53fc9c0ef6081e8854c26d9a87ad2d
Contents?: true
Size: 1.51 KB
Versions: 10
Compression:
Stored size: 1.51 KB
Contents
module Katello module EventDaemon class Monitor def initialize(services) @services = services @service_statuses = {} @services.keys.each do |service_name| @service_statuses[service_name] = { running: 'starting' } end end def start write_statuses_to_cache loop do Rails.application.executor.wrap do check_services end sleep 15 end end def write_statuses_to_cache Rails.cache.write( Katello::EventDaemon::Runner::STATUS_CACHE_KEY, @service_statuses ) end def check_services @services.each do |service_name, service_class| @service_statuses[service_name] = service_class.status rescue => error Rails.logger.error("Error occurred while pinging #{service_class}") Rails.logger.error(error.message) Rails.logger.error(error.backtrace.join("\n")) ensure if error || !@service_statuses.dig(service_name, :running) begin service_class.close service_class.run @service_statuses[service_name] = service_class.status rescue => error Rails.logger.error("Error occurred while starting #{service_class}") Rails.logger.error(error.message) Rails.logger.error(error.backtrace.join("\n")) end end end write_statuses_to_cache end end end end
Version data entries
10 entries across 10 versions & 1 rubygems