Class: ScoutApm::Agent::ExitHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/agent/exit_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ ExitHandler

Returns a new instance of ExitHandler.



6
7
8
# File 'lib/scout_apm/agent/exit_handler.rb', line 6

def initialize(context)
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/scout_apm/agent/exit_handler.rb', line 4

def context
  @context
end

Instance Method Details

#installObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/scout_apm/agent/exit_handler.rb', line 10

def install
  logger.debug "Shutdown handler not supported" and return unless exit_handler_supported?
  logger.debug "Installing Shutdown Handler"

  at_exit do
    logger.info "Shutting down Scout Agent"
    # MRI 1.9 bug drops exit codes.
    # http://bugs.ruby-lang.org/issues/5218
    if environment.ruby_19?
      status = $!.status if $!.is_a?(SystemExit)
      shutdown
      exit status if status
    else
      shutdown
    end
  end
end