开发者

Running rufus scheduler on multiple nodes problem?

Running rufus-scheduler in a Rails 3 app withou开发者_StackOverflowt any problem.

But since my app is running in cluster of nodes, app1.myapp.com - app2.myapp.com, the rufus-scheduler is running the job app(N) times.

How can I make it run only on one server?


Have you thought of this naive solution:

# at initialization

if `hostname -f` == 'app1.myapp.com'
  $scheduler = Rufus::Scheduler.start_new
  $scheduler.every '5s' do
    puts "hello world"
  end
else
  # we're on another host, do not schedule anything
  $scheduler = nil
end

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜