Added the panic capture so that information about panic gets into the log file (#3877)

* Added the panic capture so that information about it gets into the log file

* Printf -> Errorf

* Update validator/main.go  "run time" -> "Runtime"

Co-Authored-By: Raul Jordan <raul@prysmaticlabs.com>

* Update beacon-chain/main.go    "run time" -> "Runtime"

Co-Authored-By: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
Alex Nebotov 2019-11-06 19:18:51 +03:00 committed by Raul Jordan
parent 295b3a74e9
commit 5a789fca4a
2 changed files with 16 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"os"
"runtime"
runtimeDebug "runtime/debug"
golog "github.com/ipfs/go-log"
joonix "github.com/joonix/log"
@ -123,6 +124,13 @@ func main() {
return debug.Setup(ctx)
}
defer func() {
if x := recover(); x != nil {
log.Errorf("Runtime panic: %v\n%v", x, string(runtimeDebug.Stack()))
panic(x)
}
}()
if err := app.Run(os.Args); err != nil {
log.Error(err.Error())
os.Exit(1)

View File

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"runtime"
runtimeDebug "runtime/debug"
joonix "github.com/joonix/log"
"github.com/prysmaticlabs/prysm/shared/cmd"
@ -152,6 +153,13 @@ contract in order to activate the validator client`,
return nil
}
defer func() {
if x := recover(); x != nil {
log.Errorf("Runtime panic: %v\n%v", x, string(runtimeDebug.Stack()))
panic(x)
}
}()
if err := app.Run(os.Args); err != nil {
log.Error(err.Error())
os.Exit(1)