mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Panic! in the Logs (#53664)
This commit is contained in:
parent
f416651842
commit
cc777e175e
@ -127,6 +127,20 @@ func executeServer(configFile, homePath, pidFile, packaging string, traceDiagnos
|
||||
}
|
||||
}()
|
||||
|
||||
defer func() {
|
||||
// If we've managed to initialize them, this is the last place
|
||||
// where we're able to log anything that'll end up in Grafana's
|
||||
// log files.
|
||||
// Since operators are not always looking at stderr, we'll try
|
||||
// to log any and all panics that are about to crash Grafana to
|
||||
// our regular log locations before exiting.
|
||||
if r := recover(); r != nil {
|
||||
reason := fmt.Sprintf("%v", r)
|
||||
clilog.Error("Critical error", "reason", reason, "stackTrace", string(debug.Stack()))
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
|
||||
if traceDiagnostics.enabled {
|
||||
fmt.Println("diagnostics: tracing enabled", "file", traceDiagnostics.file)
|
||||
f, err := os.Create(traceDiagnostics.file)
|
||||
|
Loading…
Reference in New Issue
Block a user