lib/rocket_job/worker.rb in rocketjob-2.0.0.rc2 vs lib/rocket_job/worker.rb in rocketjob-2.0.0.rc3
- old
+ new
@@ -43,11 +43,11 @@
# When this worker process was started
key :started_at, Time
# The heartbeat information for this worker
- one :heartbeat, class_name: 'RocketJob::Heartbeat'
+ has_one :heartbeat, class_name: 'RocketJob::Heartbeat'
# Current state
# Internal use only. Do not set this field directly
key :state, Symbol, default: :starting
@@ -194,10 +194,10 @@
# - The worker process has died
# - The worker process is "hanging"
# - The worker is no longer able to communicate with the MongoDB Server
def zombie?(missed = 4)
return false unless running?
- return true if heartbeat.updated_at.nil?
+ return true if heartbeat.nil? || heartbeat.updated_at.nil?
dead_seconds = Config.instance.heartbeat_seconds * missed
(Time.now - heartbeat.updated_at) >= dead_seconds
end
# On MRI the 'concurrent-ruby-ext' gem may not be loaded