Merge pull request #898 from coolljt0725/stack
Add SIGUSR1 to print the stack of containerd
This commit is contained in:
commit
7fc91b0591
@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
@ -436,3 +437,18 @@ func interceptor(ctx gocontext.Context,
|
||||
}
|
||||
return grpc_prometheus.UnaryServerInterceptor(ctx, req, info, handler)
|
||||
}
|
||||
|
||||
func dumpStacks() {
|
||||
var (
|
||||
buf []byte
|
||||
stackSize int
|
||||
)
|
||||
bufferLen := 16384
|
||||
for stackSize == len(buf) {
|
||||
buf = make([]byte, bufferLen)
|
||||
stackSize = runtime.Stack(buf, true)
|
||||
bufferLen *= 2
|
||||
}
|
||||
buf = buf[:stackSize]
|
||||
logrus.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf)
|
||||
}
|
||||
|
@ -50,6 +50,8 @@ func handleSignals(signals chan os.Signal, server *grpc.Server) error {
|
||||
if err := reaper.Reap(); err != nil {
|
||||
log.G(global).WithError(err).Error("reap containerd processes")
|
||||
}
|
||||
case unix.SIGUSR1:
|
||||
dumpStacks()
|
||||
default:
|
||||
server.Stop()
|
||||
return nil
|
||||
|
@ -39,6 +39,8 @@ func handleSignals(signals chan os.Signal, server *grpc.Server) error {
|
||||
if err := reaper.Reap(); err != nil {
|
||||
log.G(global).WithError(err).Error("reap containerd processes")
|
||||
}
|
||||
case unix.SIGUSR1:
|
||||
dumpStacks()
|
||||
default:
|
||||
server.Stop()
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user