How can I prevent Sidekiq processing new jobs based on code version?

梦想的初衷 提交于 2019-12-11 06:56:26

问题


We are deploying versions of a sidekiq worker to Cloud Foundry as part of a continuous delivery pipeline. We need to stop workers processing new jobs if they are no longer the latest version. So:

  1. Worker v1 is running and performing a 30 min job.
  2. We deploy v2 of the worker code.
  3. v1 should continue with current jobs but not start any new ones.

CloudFoundry won't allow us to send USR1, so we need a solution that allows the workers to determine if they are the latest version before every job starts.


回答1:


Use a new queue name in your V2 codebase

e.g/

class ImportantWorker
  include Sidekiq::Worker
  sidekiq_options queue: :new_queue_name
  ....
end

and make sure you update your sidekiq config to reflect the new queue name



来源:https://stackoverflow.com/questions/26138858/how-can-i-prevent-sidekiq-processing-new-jobs-based-on-code-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!