mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix shutdown daemon during starting causes daemon crash
Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
parent
4dafd107ad
commit
3c25656efa
1 changed files with 5 additions and 6 deletions
|
@ -127,11 +127,6 @@ func (cli *DaemonCli) start() (err error) {
|
||||||
stopc := make(chan bool)
|
stopc := make(chan bool)
|
||||||
defer close(stopc)
|
defer close(stopc)
|
||||||
|
|
||||||
signal.Trap(func() {
|
|
||||||
cli.stop()
|
|
||||||
<-stopc // wait for daemonCli.start() to return
|
|
||||||
})
|
|
||||||
|
|
||||||
// warn from uuid package when running the daemon
|
// warn from uuid package when running the daemon
|
||||||
uuid.Loggerf = logrus.Warnf
|
uuid.Loggerf = logrus.Warnf
|
||||||
|
|
||||||
|
@ -258,6 +253,11 @@ func (cli *DaemonCli) start() (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
d, err := daemon.NewDaemon(cli.Config, registryService, containerdRemote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -276,7 +276,6 @@ func (cli *DaemonCli) start() (err error) {
|
||||||
initRouter(api, d)
|
initRouter(api, d)
|
||||||
|
|
||||||
cli.d = d
|
cli.d = d
|
||||||
cli.api = api
|
|
||||||
cli.setupConfigReloadTrap()
|
cli.setupConfigReloadTrap()
|
||||||
|
|
||||||
// The serve API routine never exits unless an error occurs
|
// The serve API routine never exits unless an error occurs
|
||||||
|
|
Loading…
Add table
Reference in a new issue