From e416113ac242e3c0f26e46ee06d06ce78d4a8117 Mon Sep 17 00:00:00 2001 From: avi_alima Date: Thu, 20 Aug 2015 13:35:41 +0300 Subject: [PATCH] Add ability to define minimal time between job executions to support multiple corno nodes, so two different nodes will not execute the same job Add Locking for the case that two nodes start perform job together. If execution_interval == 0.minutes, skip locking and immediately perform --- lib/crono/job.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/crono/job.rb b/lib/crono/job.rb index feabe9b..8a86b95 100644 --- a/lib/crono/job.rb +++ b/lib/crono/job.rb @@ -107,6 +107,8 @@ module Crono end def perform_before_interval? + return false if execution_interval == 0.minutes + return true if self.last_performed_at.present? && self.last_performed_at > execution_interval.ago return true if model.updated_at.present? && model.created_at != model.updated_at && model.updated_at > execution_interval.ago