multi: wrap logger to request shutdown from signal on critical error

This commit adds a shutdown logger which will send a request for
shutdown on critical errors. It uses the signal package to request safe
shutdown of the daemon. Since we init our logs in config validation,
we add a started channel to the signal package to prevent the case where
we have a critical log after the ShutdownLogger has started but before
the daemon has started listening for intercepts. In this case, we just
ignore the shutdown request.
This commit is contained in:
carla committed 2020-08-24 08:54:34 +02:00
1 parent c3821e5ad1
commit daae8a9944
6 files changed
+98 -6

No files matched your search

+4 -1
View File
@@ -39,7 +39,10 @@ func NewRotatingLogWriter() *RotatingLogWriter {
logWriter := &LogWriter{}
backendLog := btclog.NewBackend(logWriter)
return &RotatingLogWriter{
GenSubLogger: backendLog.Logger,
GenSubLogger: func(tag string) btclog.Logger {
logger := backendLog.Logger(tag)
return NewShutdownLogger(logger)
},
logWriter: logWriter,
backendLog: backendLog,
subsystemLoggers: SubLoggers{},