Ruby code to check sidekiq jobs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def check_queue(queues=[])
if queues.empty?
queues = Sidekiq::Queue.all
else
queues = queues.map { |queue| Sidekiq::Queue.new(queue) }
end
queues.each do |queue|
queue.each do |job|
p job
p job.klass, job.args, job.jid
end
end
end
def check_schedule
Sidekiq::ScheduledSet.new.each do |job|
puts job.at
end
def check_deadset
Sidekiq::DeadSet.new.each do |job|
puts job
end
end
def check_retryset
Sidekiq::RetrySet.new.each do |job|
puts job
end
end
def check_running_jobs
workers = Sidekiq::Workers.new
workers.each do |process_id, thread_id, work|
p "process_id=#{process_id} thread_id=#{thread_id}"
p work
puts "created_at=#{Time.at(work['payload']['created_at'])} enqueued_at=#{Time.at(work['payload']['enqueued_at'])} run_at=#{Time.at(work['run_at'])}"
end
end
This post is licensed under CC BY 4.0 by the author.