Last active
March 11, 2022 07:30
-
-
Save rauxalach/452d656f9ea1fd6d1a13cdc1fd95ff56 to your computer and use it in GitHub Desktop.
sidekiq cheatsheet
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
if you want to list all currently running jobs from console, try this | |
```ruby | |
workers = Sidekiq::Workers.new | |
workers.each do |_process_id, _thread_id, work| | |
p work | |
end | |
``` | |
a work is a hash. | |
to list all queue data. | |
```ruby | |
queues = Sidekiq::Queue.all | |
queues.each do |queue| | |
queue.each do |job| | |
p job.klass, job.args, job.jid | |
end | |
end | |
``` | |
for a specific queue change this to Sidekiq::Queue.new('queue_name') | |
similarly you can get all scheduled jobs using Sidekiq::ScheduledSet.new | |
stats = Sidekiq::Stats.new | |
stats.queues | |
stats.enqueued | |
stats.processed | |
stats.failed | |
scheduled_queue = Sidekiq::ScheduledSet.new | |
retry_queue = Sidekiq::RetrySet.new | |
default_queue = Sidekiq::Queue.new("default") | |
default_queue.each do | job | | |
class_arg = job.args[0].split('-').select { | arg | arg.match(' !ruby/class') }[0] | |
p class_arg.split[1].gsub '\'', '' unless class_arg.nil? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment