为什么 Rufus 两次安排第一份工作?
Why is Rufus scheduling the first job twice?
我有一个 Rails 应用程序,它使用 Rufus Scheduler 结合延迟作业来执行后台作业。还有其他工作,但我遇到问题的工作是使用以下代码在控制器中安排的:
def create
@harvest_plan = HarvestPlan.new(resource_params)
@harvest_plan.start_date = Time.parse(resource_params[:start_date])
if @harvest_plan.save
ApplicationController.new.insert_in_messages_list(session, :success, 'Harvest plan created')
schedule_harvest
redirect_to farms_path
end
end
private
def schedule_harvest
Rufus::Scheduler.singleton.every "#{@harvest_plan.hours_between}h",
:times => @harvest_plan.repetitions, :first_at => @harvest_plan.start_date do
CreateHarvestFromPlanJob.perform_later
end
end
作业应根据收获计划模型进行安排,该模型指示作业之间必须经过多少小时、第一个作业应在何时安排以及必须重复多少次。除了 第一份工作,一切都完美无缺,它确实在 first_at 指定的时间发生,但由于某种原因被安排了两次 ,延迟的工作然后执行了两次工作。我尝试使用 mutex、blocking 和 overlap 选项,但没有任何不同。在第一份工作(安排两次)之后一切正常。下一个作业按时安排,而且只安排一次。 我只有一名延迟工作人员
为什么会这样?
我是 运行 Rails 4.2.4,Ruby 2.2.2 和 Rufus 3.3.2。由于错误同时发生在 passenger 和 webrick 上,我认为这与问题无关。
Why is Rufus scheduling the first job twice?
由于您发现了一个错误:https://github.com/jmettraux/rufus-scheduler/issues/231
非常感谢!
我有一个 Rails 应用程序,它使用 Rufus Scheduler 结合延迟作业来执行后台作业。还有其他工作,但我遇到问题的工作是使用以下代码在控制器中安排的:
def create
@harvest_plan = HarvestPlan.new(resource_params)
@harvest_plan.start_date = Time.parse(resource_params[:start_date])
if @harvest_plan.save
ApplicationController.new.insert_in_messages_list(session, :success, 'Harvest plan created')
schedule_harvest
redirect_to farms_path
end
end
private
def schedule_harvest
Rufus::Scheduler.singleton.every "#{@harvest_plan.hours_between}h",
:times => @harvest_plan.repetitions, :first_at => @harvest_plan.start_date do
CreateHarvestFromPlanJob.perform_later
end
end
作业应根据收获计划模型进行安排,该模型指示作业之间必须经过多少小时、第一个作业应在何时安排以及必须重复多少次。除了 第一份工作,一切都完美无缺,它确实在 first_at 指定的时间发生,但由于某种原因被安排了两次 ,延迟的工作然后执行了两次工作。我尝试使用 mutex、blocking 和 overlap 选项,但没有任何不同。在第一份工作(安排两次)之后一切正常。下一个作业按时安排,而且只安排一次。 我只有一名延迟工作人员
为什么会这样?
我是 运行 Rails 4.2.4,Ruby 2.2.2 和 Rufus 3.3.2。由于错误同时发生在 passenger 和 webrick 上,我认为这与问题无关。
Why is Rufus scheduling the first job twice?
由于您发现了一个错误:https://github.com/jmettraux/rufus-scheduler/issues/231
非常感谢!