FIX: Heartbeat check per sidekiq process (#7873)

* FIX: Heartbeat check per sidekiq process

* Rename method

* Remove heartbeat queues of previous bootups

* Regis feedback

* Refactor before_start

* Update lib/demon/sidekiq.rb

Co-Authored-By: Régis Hanol <regis@hanol.fr>

* Update lib/demon/sidekiq.rb

Co-Authored-By: Régis Hanol <regis@hanol.fr>

* Expire redis keys after 3600 seconds

* Don't use redis to store the list of queues
This commit is contained in:
Osama Sayegh
2019-08-26 09:33:49 +03:00
committed by GitHub
parent 208c638900
commit 340855da55
6 changed files with 76 additions and 34 deletions

View File

@@ -2,19 +2,8 @@
module Jobs
class RunHeartbeat < Jobs::Base
sidekiq_options queue: 'critical'
def self.heartbeat_key
'heartbeat_last_run'
end
def execute(args)
$redis.set(self.class.heartbeat_key, Time.new.to_i.to_s)
end
def self.last_heartbeat
$redis.get(heartbeat_key).to_i
Demon::Sidekiq.trigger_heartbeat(args[:queue_name])
end
end
end

View File

@@ -7,7 +7,9 @@ module Jobs
every 3.minute
def execute(args)
Jobs.enqueue(:run_heartbeat, {})
Demon::Sidekiq::QUEUE_IDS.each do |identifier|
Jobs.enqueue(:run_heartbeat, queue_name: identifier, queue: identifier)
end
end
end
end