0

在 Rails 3 应用程序中运行 rufus-scheduler 没有任何问题。

但是由于我的应用程序在节点集群 app1.myapp.com - app2.myapp.com 中运行,因此 rufus-scheduler 正在运行作业 app(N) 次。

如何让它只在一台服务器上运行?

4

1 回答 1

5

你有没有想过这个幼稚的解决方案:

# 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

?

于 2011-09-08T20:48:36.880 回答