• sidekiq and resque


    Resque::Job.destroy

    失败任务
    jobs = Resque::Failure.count()

    jobs = Resque::Failure.all(5357,1)

    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
     
  • 相关阅读:
    数据对齐
    算法面试题集——从各大博客收集
    软件工程师规划
    链栈,顺序栈,单链队列,循环队列,非循环队列的简单实现
    C,C++文件和目录操作的一些整理
    WPF使用笔记-计时器,多线程更新界面,焦点移动等
    Heap Data Structure and Heap Sort
    YUV420P像素数据编码为JPEG图片
    根据txt文件中指定的文件名进行文件分类
    MFC显示图片和写入文件
  • 原文地址:https://www.cnblogs.com/qinyan20/p/10731229.html
Copyright © 2020-2023  润新知