2015-04-21 00:24:24 -04:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
|
|
|
|
2016-11-01 10:32:55 -04:00
|
|
|
"github.com/Sirupsen/logrus"
|
2016-10-12 18:29:47 -04:00
|
|
|
stackdump "github.com/docker/docker/pkg/signal"
|
2015-04-21 00:24:24 -04:00
|
|
|
)
|
|
|
|
|
2016-10-12 18:29:47 -04:00
|
|
|
func (d *Daemon) setupDumpStackTrap(root string) {
|
2015-04-21 00:24:24 -04:00
|
|
|
c := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(c, syscall.SIGUSR1)
|
|
|
|
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
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|