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"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/boltdb/bolt"
|
"github.com/boltdb/bolt"
|
||||||
@ -436,3 +437,18 @@ func interceptor(ctx gocontext.Context,
|
|||||||
}
|
}
|
||||||
return grpc_prometheus.UnaryServerInterceptor(ctx, req, info, handler)
|
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 {
|
if err := reaper.Reap(); err != nil {
|
||||||
log.G(global).WithError(err).Error("reap containerd processes")
|
log.G(global).WithError(err).Error("reap containerd processes")
|
||||||
}
|
}
|
||||||
|
case unix.SIGUSR1:
|
||||||
|
dumpStacks()
|
||||||
default:
|
default:
|
||||||
server.Stop()
|
server.Stop()
|
||||||
return nil
|
return nil
|
||||||
|
@ -39,6 +39,8 @@ func handleSignals(signals chan os.Signal, server *grpc.Server) error {
|
|||||||
if err := reaper.Reap(); err != nil {
|
if err := reaper.Reap(); err != nil {
|
||||||
log.G(global).WithError(err).Error("reap containerd processes")
|
log.G(global).WithError(err).Error("reap containerd processes")
|
||||||
}
|
}
|
||||||
|
case unix.SIGUSR1:
|
||||||
|
dumpStacks()
|
||||||
default:
|
default:
|
||||||
server.Stop()
|
server.Stop()
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user