2015-04-21 00:24:24 -04:00
|
|
|
// +build !windows
|
|
|
|
|
2018-02-05 16:05:59 -05:00
|
|
|
package daemon // import "github.com/docker/docker/daemon"
|
2015-04-21 00:24:24 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
|
2016-10-12 18:29:47 -04:00
|
|
|
stackdump "github.com/docker/docker/pkg/signal"
|
2017-07-26 17:42:13 -04:00
|
|
|
"github.com/sirupsen/logrus"
|
2017-05-23 10:22:32 -04:00
|
|
|
"golang.org/x/sys/unix"
|
2015-04-21 00:24:24 -04:00
|
|
|
)
|
|
|
|
|
2019-08-09 07:19:49 -04:00
|
|
|
func (daemon *Daemon) setupDumpStackTrap(root string) {
|
2015-04-21 00:24:24 -04:00
|
|
|
c := make(chan os.Signal, 1)
|
2017-05-23 10:22:32 -04:00
|
|
|
signal.Notify(c, unix.SIGUSR1)
|
2015-04-21 00:24:24 -04:00
|
|
|
go func() {
|
|
|
|
for range c {
|
2016-11-01 10:32:55 -04:00
|
|
|
path, err := stackdump.DumpStacks(root)
|
|
|
|
if err != nil {
|
|
|
|
logrus.WithError(err).Error("failed to write goroutines dump")
|
2016-10-12 18:29:47 -04:00
|
|
|
} else {
|
|
|
|
logrus.Infof("goroutine stacks written to %s", path)
|
|
|
|
}
|
2015-04-21 00:24:24 -04:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|