mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 01:27:38 +00:00
Added temp file in crashreports because git is stupid (#2157)
* added temp file in crashreports because git is stupid and wont add empty folders * added proper creating of crash report dir * changed crashreports dir to one directory up from datadir * implemented suggestions * switched back to 5d651381daf9d12cc663a7326b3b16d7bb4c1aa0 for tests/testdata
This commit is contained in:
parent
0f64df626a
commit
229d6671b9
@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
var sigc chan os.Signal
|
||||
var crashReportDir string
|
||||
|
||||
func GetSigC(sig *chan os.Signal) {
|
||||
sigc = *sig
|
||||
@ -23,22 +24,22 @@ func prettyTime() string {
|
||||
return strings.Replace(time[:19], " ", "-", 1)
|
||||
}
|
||||
|
||||
func CheckForCrashes() {
|
||||
ex, err := os.Executable()
|
||||
if err != nil {
|
||||
log.Warn(err.Error())
|
||||
func CheckForCrashes(datadir string) {
|
||||
crashReportDir = filepath.Join(datadir, "crashreports")
|
||||
if _, err := os.Stat(crashReportDir); os.IsNotExist(err) {
|
||||
os.Mkdir(crashReportDir, 0755)
|
||||
} else if err != nil {
|
||||
log.Error("log_panig.go: CheckForCrashes", "error", err)
|
||||
return
|
||||
}
|
||||
binPath := filepath.Dir(ex)
|
||||
crashReportDir := filepath.Join(binPath[:len(binPath)-10], "crashreports")
|
||||
f, err := os.Open(crashReportDir)
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
log.Error("log_panig.go: CheckForCrashes", "error", err)
|
||||
return
|
||||
}
|
||||
fileInfo, err := f.ReadDir(-1)
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
log.Error("log_panig.go: CheckForCrashes", "error", err)
|
||||
return
|
||||
}
|
||||
for _, v := range fileInfo {
|
||||
@ -46,6 +47,7 @@ func CheckForCrashes() {
|
||||
msg := fmt.Sprintf("Crashes From Previous Boots Detected. Find the stack trace in %v",
|
||||
crashReportDir)
|
||||
log.Warn(msg)
|
||||
f.Close()
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -71,16 +73,10 @@ func LogPanic(err error, stopErigon bool, panicResult interface{}) error {
|
||||
}
|
||||
|
||||
func WriteStackTraceOnPanic(stack string) {
|
||||
ex, err := os.Executable()
|
||||
if err != nil {
|
||||
log.Warn(err.Error())
|
||||
return
|
||||
}
|
||||
binPath := filepath.Dir(ex)
|
||||
fileName := filepath.Join(binPath[:len(binPath)-10], "crashreports", prettyTime()+".txt")
|
||||
fileName := filepath.Join(crashReportDir, prettyTime()+".txt")
|
||||
f, errFs := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
|
||||
if errFs != nil {
|
||||
log.Error(errFs.Error())
|
||||
log.Error("log_panic.go:WriteStackTraceOnPanic", "error", errFs)
|
||||
f.Close()
|
||||
return
|
||||
}
|
||||
|
0
crashreports/.hold
Normal file
0
crashreports/.hold
Normal file
@ -123,7 +123,7 @@ func New(conf *Config) (*Node, error) {
|
||||
node.ipc = newIPCServer(node.log, conf.IPCEndpoint())
|
||||
// Check for uncaught crashes from the previous boot and notify the user if
|
||||
// there are any
|
||||
debug.CheckForCrashes()
|
||||
debug.CheckForCrashes(conf.DataDir)
|
||||
|
||||
return node, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user