rufus-scheduler runs scheduler multiple times due to unicorn workers

我只是一个虾纸丫 提交于 2019-12-25 05:06:25

问题


I had setup scheduler in my rails3 projects's /configs/initializers/schedule.rb and it working fine, But it works 2 times and I think it is due to unicorn workers execute schedule at the same time, so it create in my database two records each time. I checked my logic and its ok and enter single record in my local machine.

I checked following but not getting idea how to stop multiple unicorn workers to execute scheduler?

https://github.com/jmettraux/rufus-scheduler/#advanced-lock-schemes

Any one got this issue? Please help if any idea.

Thanks,

P Shah


回答1:


try this

require 'rufus-scheduler'

scheduler = Rufus::Scheduler.new(:lockfile => ".rufus-scheduler.lock")

unless scheduler.down?

  scheduler.every("60") do
    # ...
  end
end



回答2:


Please try the solution described in https://github.com/jmettraux/rufus-scheduler/#lockfile--mylockfiletxt



来源:https://stackoverflow.com/questions/22958902/rufus-scheduler-runs-scheduler-multiple-times-due-to-unicorn-workers

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