Resque::Job.destroy
jobs = Resque::Failure.all(5357,1)
失败任务
jobs = Resque::Failure.count()
Resque::Failure.queues
查询工作
Resque::Worker.all
(0...Resque::Failure.count-1).to_a.each do |i|
puts i
s = Resque::Failure.all(1, 1, 'failed')
if s['payload']['args'][0]['job_class'] == "OrderCouponJob"
Resque::Failure.remove(1, 'failed')
else
puts s
break
end
end
j = 0
(0...Resque::Failure.count).to_a.each do |i|
puts i
s = Resque::Failure.all(j, 1, 'failed')
if s['payload']['args'][0]['job_class'] == "OrderCouponJob"
Resque::Failure.remove(j, 'failed')
else
puts s
j += 1
end
end
j = 0
(0...Resque::Failure.count).to_a.each do |i|
puts i
s = Resque::Failure.all(i, 1, 'failed')
puts s
end
while job = Resque.reserve('default')
# Check this job for the ActiveJob class name we're looking for;
# if it does not match, push it back onto a different queue
unless job.args.to_s.include?('PhysicalServerProvisionJob')
Resque.push('another_queue', class: job.payload_class.to_s, args: job.args)
end
end
Resque.size('default').times do
job = Resque.reserve('default')
next if job.nil? || job.args.first['arguments'].first == id
Resque.push('default', class: job.payload_class.to_s, args: job.args)
end
1
2
3
4
5
6
7
8
9
10
11
12
|
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