Skip to content

Job Management (deprecated)

Johnathan Martin edited this page Jun 25, 2024 · 1 revision

NOTE: the below code was written before the robots were switched from Resque to Sidekiq. Resque-specific calls and concepts need to be replaced with ActiveJob or Sidekiq calls/concepts.

Find Runaway Jobs

This is code we used find jobs that were proliferating (they were all related to the desc-md step in the accessionWF)

druids = []
problematic_druids = []
Resque.redis.lrange("queue:accessionWF_default",0,-1).each do |job|
  job = Resque::Job.decode(job)
  druid = job['args'].first
  job_class = job['class']
  next unless job_class == "Robots::DorRepo::Accession::DescriptiveMetadata"
  problematic_druids << druid if druids.include?(druid)
  druids << druid
end

Destroy Jobs (by class and by args)

Resque::Job.destroy('accessionWF_default', 'Robots::DorRepo::Accession::DescriptiveMetadata', "druid:md898kw3185") # destroy all descMD jobs for a given druid in a named queue
Resque::Job.destroy('accessionWF_default', 'Robots::DorRepo::Accession::DescriptiveMetadata') # destroy all descMD jobs in the named queue