debugtrap_unix.go 730 B

123456789101112131415161718192021222324252627282930313233
  1. // +build !windows
  2. package daemon
  3. import (
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "github.com/Sirupsen/logrus"
  8. stackdump "github.com/docker/docker/pkg/signal"
  9. )
  10. func (d *Daemon) setupDumpStackTrap(root string) {
  11. c := make(chan os.Signal, 1)
  12. signal.Notify(c, syscall.SIGUSR1)
  13. go func() {
  14. for range c {
  15. path, err := stackdump.DumpStacks(root)
  16. if err != nil {
  17. logrus.WithError(err).Error("failed to write goroutines dump")
  18. } else {
  19. logrus.Infof("goroutine stacks written to %s", path)
  20. }
  21. path, err = d.dumpDaemon(root)
  22. if err != nil {
  23. logrus.WithError(err).Error("failed to write daemon datastructure dump")
  24. } else {
  25. logrus.Infof("daemon datastructure dump written to %s", path)
  26. }
  27. }
  28. }()
  29. }