signal: initialize interceptor explictly
This commit is contained in:
parent
76c2b2cea2
commit
6c6bbdd365
3
lnd.go
3
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()
|
// created in the top-level scope of a main method aren't executed if os.Exit()
|
||||||
// is called.
|
// is called.
|
||||||
func Main(lisCfg ListenerCfg) error {
|
func Main(lisCfg ListenerCfg) error {
|
||||||
|
// Hook interceptor for os signals.
|
||||||
|
signal.Intercept()
|
||||||
|
|
||||||
// Load the configuration, and parse any command line options. This
|
// Load the configuration, and parse any command line options. This
|
||||||
// function will also set up logging properly.
|
// function will also set up logging properly.
|
||||||
loadedConfig, err := loadConfig()
|
loadedConfig, err := loadConfig()
|
||||||
|
@ -26,7 +26,8 @@ var (
|
|||||||
shutdownChannel = make(chan struct{})
|
shutdownChannel = make(chan struct{})
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
// Intercept starts the interception of interrupt signals.
|
||||||
|
func Intercept() {
|
||||||
signalsToCatch := []os.Signal{
|
signalsToCatch := []os.Signal{
|
||||||
os.Interrupt,
|
os.Interrupt,
|
||||||
os.Kill,
|
os.Kill,
|
||||||
|
Loading…
Reference in New Issue
Block a user