1
0

agent_check_job.rb 460 B

123456789101112131415
  1. class AgentCheckJob < ActiveJob::Base
  2. # Given an Agent id, load the Agent, call #check on it, and then save it with an updated `last_check_at` timestamp.
  3. def perform(agent_id)
  4. agent = Agent.find(agent_id)
  5. begin
  6. return if agent.unavailable?
  7. agent.check
  8. agent.last_check_at = Time.now
  9. agent.save!
  10. rescue => e
  11. agent.error "Exception during check. #{e.message}: #{e.backtrace.join("\n")}"
  12. raise
  13. end
  14. end
  15. end