Created
August 29, 2018 18:21
-
-
Save adeubank/4532eac63ecb6d124e0d49859d2958a7 to your computer and use it in GitHub Desktop.
Deleting Sidekiq Jobs From Queue, Scheduled, and Retry
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
# find them in a queue | |
queue = Sidekiq::Queue.new("default") | |
jobs = queue.map do |job| | |
if job.klass == '[JOB_CLASS]' | |
{job_id: job.jid, job_klass: job.klass, arguments: job.args} | |
end | |
end.compact | |
# the retry queue | |
retries = Sidekiq::RetrySet.new.select | |
jobs = retries.map do |job| | |
if job.klass == '[JOB_CLASS]' | |
{job_id: job.jid, job_klass: job.klass, arguments: job.args} | |
end | |
end.compact | |
# the scheduled queue | |
scheduled = Sidekiq::ScheduledSet.new.select | |
jobs = scheduled.map do |job| | |
if job.klass == '[JOB_CLASS]' | |
{job_id: job.jid, job_klass: job.klass, arguments: job.args} | |
end | |
end.compact | |
# delete jobs with `job.delete` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment