Class: Cocaine::HealthManager

Inherits:
Object
  • Object
show all
Defined in:
lib/cocaine/server/health.rb

Instance Method Summary collapse

Constructor Details

#initialize(dispatcher, options = {}) ⇒ HealthManager

Returns a new instance of HealthManager.



50
51
52
53
54
55
# File 'lib/cocaine/server/health.rb', line 50

def initialize(dispatcher, options={})
  @dispatcher = dispatcher
  options = {disown: 2.0, heartbeat: 10.0}.merge options
  @disown = DisownTimer.new(options[:disown])
  @heartbeat = HeartbeatTimer.new(options[:heartbeat])
end

Instance Method Details

#breathObject



62
63
64
65
# File 'lib/cocaine/server/health.rb', line 62

def breath
  $log.debug '[->] doing breath'
  @disown.cancel
end

#startObject



57
58
59
60
# File 'lib/cocaine/server/health.rb', line 57

def start
  $log.debug 'health manager has been started'
  @heartbeat.start { exhale }
end