erigon-pulse/common/debug/log_panic.go

29 lines
493 B
Go
Raw Normal View History

package debug
import (
"os"
"syscall"
2021-10-22 02:51:49 +00:00
"github.com/ledgerwatch/erigon-lib/common/dbg"
2021-07-29 10:23:23 +00:00
"github.com/ledgerwatch/log/v3"
)
var sigc chan os.Signal
func GetSigC(sig *chan os.Signal) {
sigc = *sig
}
2021-06-22 10:09:45 +00:00
// LogPanic - does log panic to logger and to <datadir>/crashreports then stops the process
func LogPanic() {
panicResult := recover()
if panicResult == nil {
return
}
2021-10-22 02:51:49 +00:00
log.Error("catch panic", "err", panicResult, "stack", dbg.Stack())
2021-06-22 10:09:45 +00:00
if sigc != nil {
sigc <- syscall.SIGINT
}
}