【发布时间】:2016-04-22 00:20:18
【问题描述】:
我正在使用 heroku 调度程序,每 10 分钟运行一次任务。该任务正在执行如下操作。我正在考虑如何防止下一个工作与当前工作重叠。有什么办法可以防止 cron 作业重叠问题吗?
task force_close: :environment do
#get all unvoted wine_question
questions = Question.where(closed: false)
puts "Total #{questions} of wine_question will be closed"
finish_count = 0
questions.each do |question|
begin
question.force_close!
finish_count += 1
rescue StandardError => bang
puts "question #{self.id} error when running #{bang}"
end
end
puts "Total #{finish_count} of question was closed"
end
【问题讨论】:
-
the next job get the undone active record to call force_close! again是什么意思? -
对不起我的英文,我现在改了。
标签: ruby-on-rails heroku cron