lib/resque/scheduler.rb in resque-scheduler-4.3.0 vs lib/resque/scheduler.rb in resque-scheduler-4.3.1
- old
+ new
@@ -139,15 +139,11 @@
next unless !config[interval_type].nil? && !config[interval_type].empty?
args = optionizate_interval_value(config[interval_type])
args = [args, nil, job: true] if args.is_a?(::String)
job = rufus_scheduler.send(interval_type, *args) do
- if master?
- log! "queueing #{config['class']} (#{name})"
- Resque.last_enqueued_at(name, Time.now.to_s)
- enqueue(config)
- end
+ enqueue_recurring(name, config)
end
@scheduled_jobs[name] = job
interval_defined = true
break
end
@@ -369,11 +365,17 @@
rescue Interrupt
before_shutdown if @shutdown
true
end
+ def stop_rufus_scheduler
+ rufus_scheduler.shutdown(:wait)
+ rufus_scheduler.join
+ end
+
def before_shutdown
+ stop_rufus_scheduler
release_master_lock
end
# Sets the shutdown flag, clean schedules and exits if sleeping
def shutdown
@@ -414,9 +416,17 @@
format: logformat
).build
end
private
+
+ def enqueue_recurring(name, config)
+ if master?
+ log! "queueing #{config['class']} (#{name})"
+ Resque.last_enqueued_at(name, Time.now.to_s)
+ enqueue(config)
+ end
+ end
def app_str
app_name ? "[#{app_name}]" : ''
end