class Trinidad::Lifecycle::Host::RollingReload::Takeover

Public Class Methods

new(context) click to toggle source
# File lib/trinidad/lifecycle/host/rolling_reload.rb, line 58
def initialize(context)
  @old_context = context
end

Public Instance Methods

after_start(event) click to toggle source
Calls superclass method Trinidad::Lifecycle::Base#after_start
# File lib/trinidad/lifecycle/host/rolling_reload.rb, line 62
def after_start(event)
  new_context = event.lifecycle
  new_context.remove_lifecycle_listener(self) # GC old context

  logger.debug "Stoping the old Context for [#{@old_context.path}]"

  @old_context.stop
  @old_context.work_dir = nil # make sure it's not deleted
  @old_context.destroy
  # NOTE: name might not be changed once added to a parent
  #new_context.name = @old_context.name
  super
end
failed!(new_context) click to toggle source
# File lib/trinidad/lifecycle/host/rolling_reload.rb, line 76
def failed!(new_context)
  # NOTE: this will also likely destroy() the child - new context :
  @old_context.parent.remove_child new_context
  logger.info "Failed to start new Context for [#{@old_context.path}] " + 
              "(check application logs) keeping the old one running ..."
  new_context.remove_lifecycle_listener(self)
end

Private Instance Methods

logger() click to toggle source
# File lib/trinidad/lifecycle/host/rolling_reload.rb, line 86
def logger
  Trinidad::Lifecycle::Host::RollingReload.logger
end