lib/zhong/scheduler.rb in zhong-0.1.8 vs lib/zhong/scheduler.rb in zhong-0.1.9

- old
+ new

@@ -4,11 +4,12 @@ DEFAULT_CONFIG = { timeout: 0.5, grace: 15.minutes, long_running_timeout: 5.minutes, - tz: nil + tz: nil, + heartbeat_key: "zhong:heartbeat", }.freeze def initialize(config = {}) @jobs = {} @callbacks = {} @@ -141,14 +142,14 @@ fire_callbacks(:after_run, job, time, ran) end def heartbeat(time) - @redis.setex(heartbeat_key, @config[:grace].to_i, time.to_i) + @redis.hset(config[:heartbeat_key], heartbeat_field, time.to_i) end - def heartbeat_key - @heartbeat_key ||= "zhong:heartbeat:#{`hostname`.strip}##{Process.pid}" + def heartbeat_field + @heartbeat_field ||= "#{`hostname`.strip}##{Process.pid}" end def trap_signals TRAPPED_SIGNALS.each do |sig| Signal.trap(sig) { stop }