From cc4da8112814cdbb00dbf23370f9ed764383de1f Mon Sep 17 00:00:00 2001 From: yuexiao-wang Date: Tue, 1 Aug 2017 11:32:57 +0800 Subject: [PATCH] Remove the logrus from pkg/signal Signed-off-by: yuexiao-wang --- cmd/dockerd/daemon.go | 2 +- pkg/signal/trap.go | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/dockerd/daemon.go b/cmd/dockerd/daemon.go index 1facf608a9..4e57a345c3 100644 --- a/cmd/dockerd/daemon.go +++ b/cmd/dockerd/daemon.go @@ -205,7 +205,7 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) { signal.Trap(func() { cli.stop() <-stopc // wait for daemonCli.start() to return - }) + }, logrus.StandardLogger()) // Notify that the API is active, but before daemon is set up. preNotifySystem() diff --git a/pkg/signal/trap.go b/pkg/signal/trap.go index 172bc1064f..2884dfee32 100644 --- a/pkg/signal/trap.go +++ b/pkg/signal/trap.go @@ -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)))