completed SMS gateway project
This commit is contained in:
14
app/jobs/check_gateway_health_job.rb
Normal file
14
app/jobs/check_gateway_health_job.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class CheckGatewayHealthJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
# Mark gateways as offline if no heartbeat in last 2 minutes
|
||||
offline_count = Gateway.where("last_heartbeat_at < ?", 2.minutes.ago)
|
||||
.where.not(status: "offline")
|
||||
.update_all(status: "offline")
|
||||
|
||||
if offline_count > 0
|
||||
Rails.logger.warn("Marked #{offline_count} gateways as offline due to missing heartbeat")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user