diff --git a/lnd.go b/lnd.go index d1f4e80b..f1eb5902 100644 --- a/lnd.go +++ b/lnd.go @@ -116,6 +116,9 @@ type rpcListeners func() ([]net.Listener, func(), []grpc.ServerOption, error) // created in the top-level scope of a main method aren't executed if os.Exit() // is called. func Main(lisCfg ListenerCfg) error { + // Hook interceptor for os signals. + signal.Intercept() + // Load the configuration, and parse any command line options. This // function will also set up logging properly. loadedConfig, err := loadConfig() diff --git a/signal/signal.go b/signal/signal.go index 29cbb9f5..82e503d0 100644 --- a/signal/signal.go +++ b/signal/signal.go @@ -26,7 +26,8 @@ var ( shutdownChannel = make(chan struct{}) ) -func init() { +// Intercept starts the interception of interrupt signals. +func Intercept() { signalsToCatch := []os.Signal{ os.Interrupt, os.Kill,