Module: NewRelic::Agent::AgentHelpers::Shutdown
- Included in:
- NewRelic::Agent::Agent
- Defined in:
- lib/new_relic/agent/agent_helpers/shutdown.rb
Instance Method Summary collapse
-
#graceful_disconnect ⇒ Object
This method contacts the server to send remaining data and let the server know that the agent is shutting down - this allows us to do things like accurately set the end of the lifetime of the process.
-
#shutdown ⇒ Object
Attempt a graceful shutdown of the agent, flushing any remaining data.
- #shutdown_service ⇒ Object
- #untraced_graceful_disconnect ⇒ Object
Instance Method Details
#graceful_disconnect ⇒ Object
This method contacts the server to send remaining data and let the server know that the agent is shutting down - this allows us to do things like accurately set the end of the lifetime of the process
If this process comes from a parent process, it will not disconnect, so that the parent process can continue to send data
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/new_relic/agent/agent_helpers/shutdown.rb', line 42 def graceful_disconnect if connected? begin @service.request_timeout = 10 @events.notify(:before_shutdown) transmit_data_types shutdown_service ::NewRelic::Agent.logger.debug('Graceful disconnect complete') rescue Timeout::Error, StandardError => e ::NewRelic::Agent.logger.debug("Error when disconnecting #{e.class.name}: #{e.}") end else ::NewRelic::Agent.logger.debug('Bypassing graceful disconnect - agent not connected') end end |
#shutdown ⇒ Object
Attempt a graceful shutdown of the agent, flushing any remaining data.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/new_relic/agent/agent_helpers/shutdown.rb', line 11 def shutdown return unless started? ::NewRelic::Agent.logger.info('Starting Agent shutdown') stop_event_loop trap_signals_for_litespeed untraced_graceful_disconnect revert_to_default_configuration @started = nil Control.reset end |
#shutdown_service ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/new_relic/agent/agent_helpers/shutdown.rb', line 60 def shutdown_service if @connected_pid == $$ && !@service.kind_of?(NewRelic::Agent::NewRelicService) ::NewRelic::Agent.logger.debug('Sending New Relic service agent run shutdown message') @service.shutdown else ::NewRelic::Agent.logger.debug("This agent connected from parent process #{@connected_pid}--not sending " \ 'shutdown') end end |