lib/zhong/scheduler.rb in zhong-0.1.2 vs lib/zhong/scheduler.rb in zhong-0.1.3
- old
+ new
@@ -37,11 +37,11 @@
@error_handler = block if block_given?
@error_handler
end
def on(event, &block)
- fail "Unsupported callback #{event}" unless [:before_tick, :after_tick, :before_run, :after_run].include?(event.to_sym)
+ fail "unknown callback #{event}" unless [:before_tick, :after_tick, :before_run, :after_run].include?(event.to_sym)
(@callbacks[event.to_sym] ||= []) << block
end
def start
TRAPPED_SIGNALS.each do |sig|
@@ -54,15 +54,17 @@
if fire_callbacks(:before_tick)
now = redis_time
jobs.each do |_, job|
if fire_callbacks(:before_run, job, now)
- job.run(now)
+ job.run(now, error_handler)
fire_callbacks(:after_run, job, now)
end
end
fire_callbacks(:after_tick)
+
+ GC.start
sleep(interval)
end
break if @stop