lib/gaspar.rb in gaspar-0.1.2 vs lib/gaspar.rb in gaspar-0.1.3

- old
+ new

@@ -90,13 +90,15 @@ schedule :every, timing, args, options, &block end def cron(timing, *args, &block) options = args.extract_options! - next_fire = Rufus::CronLine.new(timing).next_time + cron = Rufus::CronLine.new(timing) + next_fire = cron.next_time + next_next_fire = cron.next_time(next_fire + 0.001) - options[:period] = next_fire.to_i - Time.now.to_i + options[:period] = next_next_fire.to_i - next_fire.to_i schedule :cron, timing, args, options, &block end private @@ -145,10 +147,10 @@ log "#{Process.pid} running #{name}" # ...set the lock to expire, which makes sure that staggered workers with out-of-sync clocks don't lock { @running_jobs += 1 } @redis.expire key, expiry.to_i # ...and then run the job - run_callbacks(:run) { block.call } + run_callbacks(:run, &block) lock { @running_jobs -= 1 } end end end \ No newline at end of file