how to delete a job in sidekiq

前端 未结 8 1991
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 20:32

I am using sidekiq in my rails app. Users of my app create reports that start a sidekiq job. However, sometimes users want to be able to cancel \"processing\" reports. Delet

相关标签:
8条回答
  • 2020-12-07 21:19

    Or you can use sidekiq page on rails server.

    For example, http://localhost:3000/sidekiq, you can stop/remove the sidekiq jobs.

    Before that, you have to updates the routes.rb.

    require 'sidekiq/web'
    mount Sidekiq::Web => '/sidekiq'
    
    0 讨论(0)
  • 2020-12-07 21:20

    If you want to cancel a scheduled job, I'm not sure about @KimiGao's answer, but this is what I adapted from Sidekiq's current API documentation:

    jid = MyCustomWorker.perform_async
    
    r = Sidekiq::ScheduledSet.new
    jobs = r.select{|job| job.jid == jid }
    jobs.each(&:delete)
    

    Hope it helps.

    0 讨论(0)
提交回复
热议问题