58 lines
2.0 KiB
Diff
58 lines
2.0 KiB
Diff
From 3e25022a5aee939a73d67e0bcbd90dd1d343b9d4 Mon Sep 17 00:00:00 2001
|
|
From: lixiang172 <lixiang172@huawei.com>
|
|
Date: Tue, 12 Feb 2019 15:22:06 +0800
|
|
Subject: [PATCH] containerd-shim: Dump log to file when docker received signal
|
|
|
|
reason: Dump stack log to file when docker received "kill -SIGUSR1
|
|
PID" signal
|
|
The name of log files is "shim-stack-[time].log".
|
|
The log file can be found at:
|
|
/run/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/container-id/shim-stack-[time].log
|
|
|
|
Change-Id: I6d7e03c9a0fd36e9a76f1dd45cfd5312985d03f8
|
|
Signed-off-by: lixiang172 <lixiang172@huawei.com>
|
|
---
|
|
cmd/containerd-shim/main_unix.go | 3 +++
|
|
vendor/github.com/sirupsen/logrus/exported.go | 4 ++++
|
|
2 files changed, 7 insertions(+)
|
|
|
|
diff --git a/cmd/containerd-shim/main_unix.go b/cmd/containerd-shim/main_unix.go
|
|
index 942f354..6c3326f 100644
|
|
--- a/cmd/containerd-shim/main_unix.go
|
|
+++ b/cmd/containerd-shim/main_unix.go
|
|
@@ -267,6 +267,8 @@ func handleSignals(logger *logrus.Entry, signals chan os.Signal, server *ttrpc.S
|
|
}
|
|
}
|
|
|
|
+const stacksLogNameTemplate = "shim-stacks-%s.log"
|
|
+
|
|
func dumpStacks(logger *logrus.Entry) {
|
|
var (
|
|
buf []byte
|
|
@@ -279,6 +281,7 @@ func dumpStacks(logger *logrus.Entry) {
|
|
bufferLen *= 2
|
|
}
|
|
buf = buf[:stackSize]
|
|
+ logrus.Devour(ioutil.WriteFile(fmt.Sprintf(stacksLogNameTemplate, strings.Replace(time.Now().Format(time.RFC3339), ":", "", -1)), buf, 0600))
|
|
logger.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf)
|
|
}
|
|
|
|
diff --git a/vendor/github.com/sirupsen/logrus/exported.go b/vendor/github.com/sirupsen/logrus/exported.go
|
|
index 017c30c..7acc41f 100644
|
|
--- a/vendor/github.com/sirupsen/logrus/exported.go
|
|
+++ b/vendor/github.com/sirupsen/logrus/exported.go
|
|
@@ -179,6 +179,10 @@ func FatalFn(fn LogFunction) {
|
|
std.FatalFn(fn)
|
|
}
|
|
|
|
+// Devour will do nothing and return directly
|
|
+func Devour(args ...interface{}) {
|
|
+}
|
|
+
|
|
// Tracef logs a message at level Trace on the standard logger.
|
|
func Tracef(format string, args ...interface{}) {
|
|
std.Tracef(format, args...)
|
|
--
|
|
2.33.0
|
|
|