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.
This commit is contained in:
Olaoluwa Osuntokun 2018-06-29 12:18:19 -07:00
parent c045defd0f
commit 076fc71261
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

6
lnd.go
View File

@ -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.