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