lib/rocket_job/plugins/cron.rb in rocketjob-5.1.1 vs lib/rocket_job/plugins/cron.rb in rocketjob-5.2.0.beta1
- old
+ new
@@ -1,6 +1,6 @@
-require 'active_support/concern'
+require "active_support/concern"
module RocketJob
module Plugins
# Allow jobs to run on a predefined schedule, much like a crontab.
#
@@ -24,19 +24,21 @@
# Prevent auto restart if this job does not have a cron schedule.
# Overrides: RocketJob::Plugins::Restart#rocket_job_restart_new_instance
def rocket_job_restart_new_instance
return unless cron_schedule
+
super
end
# On failure:
# - create a new instance scheduled to run in the future.
# - clear out the `cron_schedule` so this instance will not schedule another instance to run on completion.
# Overrides: RocketJob::Plugins::Restart#rocket_job_restart_abort
def rocket_job_restart_abort
return unless cron_schedule
+
rocket_job_restart_new_instance
update_attribute(:cron_schedule, nil)
end
end
@@ -52,17 +54,19 @@
private
def rocket_job_cron_set_run_at
return unless cron_schedule
+
self.run_at = rocket_job_cron_next_time if cron_schedule_changed? && !run_at_changed?
end
def rocket_job_cron_valid
return unless cron_schedule
+
RocketJob::Plugins::Rufus::CronLine.new(cron_schedule)
- rescue ArgumentError => exc
- errors.add(:cron_schedule, exc.message)
+ rescue ArgumentError => e
+ errors.add(:cron_schedule, e.message)
end
end
end
end