|
@@ -12,7 +12,6 @@ import (
|
|
|
"time"
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
- "github.com/sirupsen/logrus"
|
|
|
)
|
|
|
|
|
|
// Trap sets up a simplified signal "trap", appropriate for common
|
|
@@ -27,7 +26,9 @@ import (
|
|
|
// the docker daemon is not restarted and also running under systemd.
|
|
|
// Fixes https://github.com/docker/docker/issues/19728
|
|
|
//
|
|
|
-func Trap(cleanup func()) {
|
|
|
+func Trap(cleanup func(), logger interface {
|
|
|
+ Info(args ...interface{})
|
|
|
+}) {
|
|
|
c := make(chan os.Signal, 1)
|
|
|
// we will handle INT, TERM, QUIT, SIGPIPE here
|
|
|
signals := []os.Signal{os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGPIPE}
|
|
@@ -40,7 +41,7 @@ func Trap(cleanup func()) {
|
|
|
}
|
|
|
|
|
|
go func(sig os.Signal) {
|
|
|
- logrus.Infof("Processing signal '%v'", sig)
|
|
|
+ logger.Info(fmt.Sprintf("Processing signal '%v'", sig))
|
|
|
switch sig {
|
|
|
case os.Interrupt, syscall.SIGTERM:
|
|
|
if atomic.LoadUint32(&interruptCount) < 3 {
|
|
@@ -54,11 +55,11 @@ func Trap(cleanup func()) {
|
|
|
}
|
|
|
} else {
|
|
|
// 3 SIGTERM/INT signals received; force exit without cleanup
|
|
|
- logrus.Info("Forcing docker daemon shutdown without cleanup; 3 interrupts received")
|
|
|
+ logger.Info("Forcing docker daemon shutdown without cleanup; 3 interrupts received")
|
|
|
}
|
|
|
case syscall.SIGQUIT:
|
|
|
DumpStacks("")
|
|
|
- logrus.Info("Forcing docker daemon shutdown without cleanup on SIGQUIT")
|
|
|
+ logger.Info("Forcing docker daemon shutdown without cleanup on SIGQUIT")
|
|
|
}
|
|
|
//for the SIGINT/TERM, and SIGQUIT non-clean shutdown case, exit with 128 + signal #
|
|
|
os.Exit(128 + int(sig.(syscall.Signal)))
|