From 076fc712619ca4b6ee518c7ab4c263cbae51108e Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 29 Jun 2018 12:18:19 -0700 Subject: [PATCH] lnd: only print shutdown message if logs are initialized In this commit, we fix a slight bug recently introduced by the addition of the new signal package. As we now use a regular defer for many actions, it may be possible that the logs aren't yet initialized (for example, lnd -h), which can cause a panic if the shutdown procedure goes to log before the logs have been initialized. --- lnd.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lnd.go b/lnd.go index 0561cdd3..ffd05fff 100644 --- a/lnd.go +++ b/lnd.go @@ -93,7 +93,11 @@ var ( // defers created in the top-level scope of a main method aren't executed if // os.Exit() is called. func lndMain() error { - defer ltndLog.Info("Shutdown complete") + defer func() { + if logRotatorPipe != nil { + ltndLog.Info("Shutdown complete") + } + }() // Load the configuration, and parse any command line options. This // function will also set up logging properly.