簡體   English   中英

在rufus-scheduler中調用rake任務

[英]invoking a rake task inside a rufus-scheduler

我正在嘗試在如下所示的調度程序中運行rake任務

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

rake任務僅在第一次執行。 但是調度程序似乎在給定的時間間隔內運行。

任何幫助贊賞。

Rake是一個依賴處理器。 它只運行一次任務,除非你另有說明。 請參閱http://rake.rubyforge.org/classes/Rake/Task.html#M000115您需要

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM