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
+7
-8
@@ -14,10 +14,6 @@ import (
|
||||
// RotatingLogWriter is a wrapper around the LogWriter that supports log file
|
||||
// rotation.
|
||||
type RotatingLogWriter struct {
|
||||
// GenSubLogger is a function that returns a new logger for a subsystem
|
||||
// belonging to the current RotatingLogWriter.
|
||||
GenSubLogger func(string) btclog.Logger
|
||||
|
||||
logWriter *LogWriter
|
||||
|
||||
backendLog *btclog.Backend
|
||||
@@ -39,16 +35,19 @@ func NewRotatingLogWriter() *RotatingLogWriter {
|
||||
logWriter := &LogWriter{}
|
||||
backendLog := btclog.NewBackend(logWriter)
|
||||
return &RotatingLogWriter{
|
||||
GenSubLogger: func(tag string) btclog.Logger {
|
||||
logger := backendLog.Logger(tag)
|
||||
return NewShutdownLogger(logger)
|
||||
},
|
||||
logWriter: logWriter,
|
||||
backendLog: backendLog,
|
||||
subsystemLoggers: SubLoggers{},
|
||||
}
|
||||
}
|
||||
|
||||
// GenSubLogger creates a new sublogger. A shutdown callback function
|
||||
// is provided to be able to shutdown in case of a critical error.
|
||||
func (r *RotatingLogWriter) GenSubLogger(tag string, shutdown func()) btclog.Logger {
|
||||
logger := r.backendLog.Logger(tag)
|
||||
return NewShutdownLogger(logger, shutdown)
|
||||
}
|
||||
|
||||
// RegisterSubLogger registers a new subsystem logger.
|
||||
func (r *RotatingLogWriter) RegisterSubLogger(subsystem string,
|
||||
logger btclog.Logger) {
|
||||
|
||||
Reference in new issue
Block a user