From 67bf28cc777513cb52c39d0e7961420c1690173b Mon Sep 17 00:00:00 2001
From: xiadanni1 <xiadanni1@huawei.com>
Date: Tue, 3 Mar 2020 09:01:22 +0800
Subject: [PATCH] containerd:save dumpstack to file

Change-Id: I54a41a13b4523de279337a9ff208347859c0fb4d
Signed-off-by: xiadanni1 <xiadanni1@huawei.com>
---
 cmd/containerd/command/main.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cmd/containerd/command/main.go b/cmd/containerd/command/main.go
index 9897dff..3d54b50 100644
--- a/cmd/containerd/command/main.go
+++ b/cmd/containerd/command/main.go
@@ -20,11 +20,13 @@ import (
 	gocontext "context"
 	"fmt"
 	"io"
+	"io/ioutil"
 	"net"
 	"os"
 	"os/signal"
 	"path/filepath"
 	"runtime"
+	"strings"
 	"time"
 
 	"github.com/containerd/containerd/defaults"
@@ -376,6 +378,7 @@ func dumpStacks(writeToFile bool) {
 		bufferLen *= 2
 	}
 	buf = buf[:stackSize]
+	logrus.Devour(ioutil.WriteFile(fmt.Sprintf("/var/run/docker/containerd/containerd-stacks-%s.log", strings.Replace(time.Now().Format(time.RFC3339), ":", "", -1)), buf, 0600))
 	log.L.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf)
 
 	if writeToFile {
-- 
2.33.0

