Skip to content

Commit

Permalink
Fix shutdown daemon during starting causes daemon crash
Browse files Browse the repository at this point in the history
Signed-off-by: Lei Jitang <[email protected]>
  • Loading branch information
coolljt0725 committed Jun 13, 2016
1 parent 4dafd10 commit 3c25656
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmd/dockerd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ func (cli *DaemonCli) start() (err error) {
stopc := make(chan bool)
defer close(stopc)

signal.Trap(func() {
cli.stop()
<-stopc // wait for daemonCli.start() to return
})

// warn from uuid package when running the daemon
uuid.Loggerf = logrus.Warnf

Expand Down Expand Up @@ -258,6 +253,11 @@ func (cli *DaemonCli) start() (err error) {
if err != nil {
return err
}
cli.api = api
signal.Trap(func() {
cli.stop()
<-stopc // wait for daemonCli.start() to return
})

d, err := daemon.NewDaemon(cli.Config, registryService, containerdRemote)
if err != nil {
Expand All @@ -276,7 +276,6 @@ func (cli *DaemonCli) start() (err error) {
initRouter(api, d)

cli.d = d
cli.api = api
cli.setupConfigReloadTrap()

// The serve API routine never exits unless an error occurs
Expand Down

0 comments on commit 3c25656

Please sign in to comment.