forked from discourse/discourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: script to analyze status of sidekiq queue
This returns a proper count of all queued jobs and finds potential dupes
- Loading branch information
1 parent
5429c9b
commit 1226474
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require File.expand_path("../../config/environment", __FILE__) | ||
|
||
queues = %w{default low ultra_low critical}.map { |name| Sidekiq::Queue.new(name) }.lazy.flat_map(&:lazy) | ||
|
||
stats = Hash.new(0) | ||
|
||
queues.each do |j| | ||
stats[j.klass] += 1 | ||
end | ||
|
||
stats.sort_by { |a, b| -b }.each do |name, count| | ||
puts "#{name}: #{count}" | ||
end | ||
|
||
dupes = Hash.new([]) | ||
queues.each do |j| | ||
key = "#{j.klass} #{j.args}" | ||
dupes[key] << j | ||
end | ||
|
||
total = 0 | ||
|
||
dupes.each do |k, jobs| | ||
next if jobs.length == 1 | ||
total += job.length - 1 | ||
puts "dupe found" | ||
p jobs | ||
end | ||
|
||
puts | ||
puts "#{total} dupelicate jobs found!" |