Remove the logrus from pkg/signal

Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
This commit is contained in:
yuexiao-wang 2017-08-01 11:32:57 +08:00
parent 8af4db6f00
commit cc4da81128
2 changed files with 7 additions and 6 deletions

View file

@ -205,7 +205,7 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
signal.Trap(func() { signal.Trap(func() {
cli.stop() cli.stop()
<-stopc // wait for daemonCli.start() to return <-stopc // wait for daemonCli.start() to return
}) }, logrus.StandardLogger())
// Notify that the API is active, but before daemon is set up. // Notify that the API is active, but before daemon is set up.
preNotifySystem() preNotifySystem()

View file

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