lib/daemon_kit/initializer.rb in kennethkalmer-daemon-kit-0.1.7.8 vs lib/daemon_kit/initializer.rb in kennethkalmer-daemon-kit-0.1.7.9
- old
+ new
@@ -58,14 +58,17 @@
def self.continue!
initializer = new DaemonKit.configuration
initializer.after_daemonize
end
- def self.shutdown
+ def self.shutdown( clean = false )
+ return unless $daemon_kit_shutdown_hooks_ran.nil?
+ $daemon_kit_shutdown_hooks_ran = true
+
DaemonKit.logger.info "Running shutdown hooks"
- log_exceptions if DaemonKit.configuration.backtraces
+ log_exceptions if DaemonKit.configuration.backtraces && !clean
DaemonKit.logger.warn "Shutting down #{DaemonKit.configuration.daemon_name}"
exit
end
@@ -160,10 +163,10 @@
DaemonKit.logger.close
}
end
def initialize_signal_traps
- term_proc = Proc.new { DaemonKit::Initializer.shutdown }
+ term_proc = Proc.new { DaemonKit::Initializer.shutdown( true ) }
configuration.trap( 'INT', term_proc )
configuration.trap( 'TERM', term_proc )
at_exit { DaemonKit::Initializer.shutdown }
end