Skip to main content

Deleting stuff in Sidekiq

Dealing with queued tasks (this will delete queued tasks, will not delete currently running tasks​

Sidekiq::Queue.new("default").each do |entry|
#puts entry['args'][0].inspect
begin
if entry['args'][0].include?('4936501')
puts "I want to delete this: #{entry['args']}"
entry.delete
end
rescue
if entry['args'].include?('4936501')
puts "I want to delete this: #{entry['args']}"
entry.delete
end
end
end

Dealing with Scheduled tasks​

Sidekiq::ScheduledSet.new.each do |shit|
if shit.args[0].include?('campaign_email_template')
puts "I wannt to delete #{shit.inspect}"
# shit.delete
end
end

Sidekiq::ScheduledSet.new.each do |shit|
if shit.args[0].include?('crm_survey_email')
puts "I wannt to delete #{shit.inspect}"
# shit.delete
end
end

Dealing with processes​

workers = Sidekiq::Workers.new
workers.size
workers.each do |k, v|
puts k.inspect
puts v.inspect
end
workers.each do |process_id, thread_id, work|
begin
puts "#{process_id.inspect}, #{thread_id.inspect}, #{work.inspect}"
rescue
end
end

process_id is a unique identifier per Sidekiq process thread_id is a unique identifier per thread work is a Hash which looks like: { 'queue' => name, 'run_at' => timestamp, 'payload' => msg } run_at is an epoch Integer. payload is a Hash which looks like: { 'retry' => true, 'queue' => 'default', 'class' => 'Redacted', 'args' => [1, 2, 'foo'], 'jid' => '80b1e7e46381a20c0c567285', 'enqueued_at' => 1427811033.2067106 }