signal: handle shutdown properly
This addresses issues related to the mobile lnd builds, where calling `stopDaemon` and subsequently calling LndMobile's `Start` results in crash.
This commit is contained in:
1 parent
6046c5cf86
commit
ada1bc701c
11 files changed
+170
-129
No files matched your search
@@ -36,6 +36,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/routing"
|
||||
"github.com/lightningnetwork/lnd/signal"
|
||||
"github.com/lightningnetwork/lnd/tor"
|
||||
)
|
||||
|
||||
@@ -510,7 +511,7 @@ func DefaultConfig() Config {
|
||||
// 2) Pre-parse the command line to check for an alternative config file
|
||||
// 3) Load configuration file overwriting defaults with any specified options
|
||||
// 4) Parse CLI options and overwrite/add any specified options
|
||||
func LoadConfig() (*Config, error) {
|
||||
func LoadConfig(interceptor signal.Interceptor) (*Config, error) {
|
||||
// Pre-parse the command line options to pick up an alternative config
|
||||
// file.
|
||||
preCfg := DefaultConfig()
|
||||
@@ -563,7 +564,7 @@ func LoadConfig() (*Config, error) {
|
||||
}
|
||||
|
||||
// Make sure everything we just loaded makes sense.
|
||||
cleanCfg, err := ValidateConfig(cfg, usageMessage)
|
||||
cleanCfg, err := ValidateConfig(cfg, usageMessage, interceptor)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -581,7 +582,8 @@ func LoadConfig() (*Config, error) {
|
||||
// ValidateConfig check the given configuration to be sane. This makes sure no
|
||||
// illegal values or combination of values are set. All file system paths are
|
||||
// normalized. The cleaned up config is returned on success.
|
||||
func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
||||
func ValidateConfig(cfg Config, usageMessage string,
|
||||
interceptor signal.Interceptor) (*Config, error) {
|
||||
// If the provided lnd directory is not the default, we'll modify the
|
||||
// path to all of the files and directories that will live within it.
|
||||
lndDir := CleanAndExpandPath(cfg.LndDir)
|
||||
@@ -1151,7 +1153,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
||||
}
|
||||
|
||||
// Initialize logging at the default logging level.
|
||||
SetupLoggers(cfg.LogWriter)
|
||||
SetupLoggers(cfg.LogWriter, interceptor)
|
||||
err = cfg.LogWriter.InitLogRotator(
|
||||
filepath.Join(cfg.LogDir, defaultLogFilename),
|
||||
cfg.MaxLogFileSize, cfg.MaxLogFiles,
|
||||
|
||||
Reference in new issue
Block a user