mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37: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 sigc chan os.Signal
|
||||||
|
var crashReportDir string
|
||||||
|
|
||||||
func GetSigC(sig *chan os.Signal) {
|
func GetSigC(sig *chan os.Signal) {
|
||||||
sigc = *sig
|
sigc = *sig
|
||||||
@ -23,22 +24,22 @@ func prettyTime() string {
|
|||||||
return strings.Replace(time[:19], " ", "-", 1)
|
return strings.Replace(time[:19], " ", "-", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckForCrashes() {
|
func CheckForCrashes(datadir string) {
|
||||||
ex, err := os.Executable()
|
crashReportDir = filepath.Join(datadir, "crashreports")
|
||||||
if err != nil {
|
if _, err := os.Stat(crashReportDir); os.IsNotExist(err) {
|
||||||
log.Warn(err.Error())
|
os.Mkdir(crashReportDir, 0755)
|
||||||
|
} else if err != nil {
|
||||||
|
log.Error("log_panig.go: CheckForCrashes", "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
binPath := filepath.Dir(ex)
|
|
||||||
crashReportDir := filepath.Join(binPath[:len(binPath)-10], "crashreports")
|
|
||||||
f, err := os.Open(crashReportDir)
|
f, err := os.Open(crashReportDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err.Error())
|
log.Error("log_panig.go: CheckForCrashes", "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fileInfo, err := f.ReadDir(-1)
|
fileInfo, err := f.ReadDir(-1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err.Error())
|
log.Error("log_panig.go: CheckForCrashes", "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range fileInfo {
|
for _, v := range fileInfo {
|
||||||
@ -46,6 +47,7 @@ func CheckForCrashes() {
|
|||||||
msg := fmt.Sprintf("Crashes From Previous Boots Detected. Find the stack trace in %v",
|
msg := fmt.Sprintf("Crashes From Previous Boots Detected. Find the stack trace in %v",
|
||||||
crashReportDir)
|
crashReportDir)
|
||||||
log.Warn(msg)
|
log.Warn(msg)
|
||||||
|
f.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,16 +73,10 @@ func LogPanic(err error, stopErigon bool, panicResult interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func WriteStackTraceOnPanic(stack string) {
|
func WriteStackTraceOnPanic(stack string) {
|
||||||
ex, err := os.Executable()
|
fileName := filepath.Join(crashReportDir, prettyTime()+".txt")
|
||||||
if err != nil {
|
|
||||||
log.Warn(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
binPath := filepath.Dir(ex)
|
|
||||||
fileName := filepath.Join(binPath[:len(binPath)-10], "crashreports", prettyTime()+".txt")
|
|
||||||
f, errFs := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
|
f, errFs := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
|
||||||
if errFs != nil {
|
if errFs != nil {
|
||||||
log.Error(errFs.Error())
|
log.Error("log_panic.go:WriteStackTraceOnPanic", "error", errFs)
|
||||||
f.Close()
|
f.Close()
|
||||||
return
|
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())
|
node.ipc = newIPCServer(node.log, conf.IPCEndpoint())
|
||||||
// Check for uncaught crashes from the previous boot and notify the user if
|
// Check for uncaught crashes from the previous boot and notify the user if
|
||||||
// there are any
|
// there are any
|
||||||
debug.CheckForCrashes()
|
debug.CheckForCrashes(conf.DataDir)
|
||||||
|
|
||||||
return node, nil
|
return node, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user