Browse code

Remove the logrus from pkg/signal

Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>

yuexiao-wang authored on 2017/08/01 12:32:57
Showing 2 changed files
... ...
@@ -205,7 +205,7 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
205 205
 	signal.Trap(func() {
206 206
 		cli.stop()
207 207
 		<-stopc // wait for daemonCli.start() to return
208
-	})
208
+	}, logrus.StandardLogger())
209 209
 
210 210
 	// Notify that the API is active, but before daemon is set up.
211 211
 	preNotifySystem()
... ...
@@ -12,7 +12,6 @@ import (
12 12
 	"time"
13 13
 
14 14
 	"github.com/pkg/errors"
15
-	"github.com/sirupsen/logrus"
16 15
 )
17 16
 
18 17
 // Trap sets up a simplified signal "trap", appropriate for common
... ...
@@ -27,7 +26,9 @@ import (
27 27
 //   the docker daemon is not restarted and also running under systemd.
28 28
 //   Fixes https://github.com/docker/docker/issues/19728
29 29
 //
30
-func Trap(cleanup func()) {
30
+func Trap(cleanup func(), logger interface {
31
+	Info(args ...interface{})
32
+}) {
31 33
 	c := make(chan os.Signal, 1)
32 34
 	// we will handle INT, TERM, QUIT, SIGPIPE here
33 35
 	signals := []os.Signal{os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGPIPE}
... ...
@@ -40,7 +41,7 @@ func Trap(cleanup func()) {
40 40
 			}
41 41
 
42 42
 			go func(sig os.Signal) {
43
-				logrus.Infof("Processing signal '%v'", sig)
43
+				logger.Info(fmt.Sprintf("Processing signal '%v'", sig))
44 44
 				switch sig {
45 45
 				case os.Interrupt, syscall.SIGTERM:
46 46
 					if atomic.LoadUint32(&interruptCount) < 3 {
... ...
@@ -54,11 +55,11 @@ func Trap(cleanup func()) {
54 54
 						}
55 55
 					} else {
56 56
 						// 3 SIGTERM/INT signals received; force exit without cleanup
57
-						logrus.Info("Forcing docker daemon shutdown without cleanup; 3 interrupts received")
57
+						logger.Info("Forcing docker daemon shutdown without cleanup; 3 interrupts received")
58 58
 					}
59 59
 				case syscall.SIGQUIT:
60 60
 					DumpStacks("")
61
-					logrus.Info("Forcing docker daemon shutdown without cleanup on SIGQUIT")
61
+					logger.Info("Forcing docker daemon shutdown without cleanup on SIGQUIT")
62 62
 				}
63 63
 				//for the SIGINT/TERM, and SIGQUIT non-clean shutdown case, exit with 128 + signal #
64 64
 				os.Exit(128 + int(sig.(syscall.Signal)))