github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/daemon/debugtrap_unix.go (about)

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