Show stack-trace from panic in weave-npc
Rather than exiting silently, fetch the stack trace and print that for the user to understand what happened. Exit via existing fatal-error code.
This commit is contained in:
1 parent
23a827088b
commit
4795ba5807
1 file changed
+5
-1
@@ -2,8 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
goruntime "runtime"
|
||||
"syscall"
|
||||
|
||||
"github.com/coreos/go-iptables/iptables"
|
||||
@@ -218,7 +220,9 @@ func hCtx() context.Context {
|
||||
|
||||
func stopOnPanicRecover() {
|
||||
if r := recover(); r != nil {
|
||||
os.Exit(1)
|
||||
buf := make([]byte, 1<<20)
|
||||
stacklen := goruntime.Stack(buf, false)
|
||||
handleFatal(fmt.Errorf("panic: %v \n%s", r, buf[:stacklen]))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user