开发者

invoking a rake task inside a rufus-scheduler

I am trying to run a rake task inside a scheduler l开发者_高级运维ike below

scheduler = Rufus::Scheduler.new
scheduler.start

schedule.schedule(chron) do
puts "in scheduler"
begin
ENV['RAILS_ENV']='production'
Rake::Task['connection'].invoke
rescue Exception => e
puts "error"
end

the rake task is executed only for the first time. but the scheduler seem to be running in the given interval.

Any help appreciated.


Rake is a dependency processor. It runs a task only once unless you tell it otherwise. See http://rake.rubyforge.org/classes/Rake/Task.html#M000115 You need to

def force_invoke(task)
  task.reenable
  task.invoke
end
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜