sidekiq 删除相关worker

Sidekiq::Queue.new('default').select do |job|
    job.klass == 'WorkerClass' && job.args[0]['xxx'] == "25471"
end.each(&:delete)


Sidekiq::RetrySet.new.select do |job|
    job.klass == 'WorkerClass' && job.args[0]['xxx'] == "25471"
end.each(&:delete)

Sidekiq::RetrySet.new.select do |job|
    job.klass ==  'WorkerClass' && job.args[0] == 19911
end.each(&:delete)

 删除重复work

Sidekiq::Queue.new('default').select do |job|
    job.klass == 'WorkerClass'
end.each_with_object(Hash.new { 0 }) { |w, hash| hash[w.args['xxx']] += 1 }.delete_if { |key, value| value == 1 }

 查找执行中的worker

Sidekiq::Workers.new.select do |_process_id, _thread_id, work|
      work['payload']['class'] = 'WorkerClass' &&
                                 work['payload']['args'][0]['xxx'].to_s == 'xxx'
end

 

posted @ 2016-02-23 20:36  耿小曾  阅读(368)  评论(0编辑  收藏  举报