mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Engine.Shutdown only waits 5 seconds for active jobs to complete
Signed-off-by: Solomon Hykes <solomon@docker.com>
This commit is contained in:
parent
92105ea0fa
commit
eb79dc14fe
1 changed files with 13 additions and 4 deletions
|
@ -164,11 +164,20 @@ func (eng *Engine) Shutdown() {
|
|||
// This requires all concurrent calls to check for shutdown, otherwise
|
||||
// it might cause a race.
|
||||
|
||||
// Wait for all jobs to complete
|
||||
eng.tasks.Wait()
|
||||
// Wait for all jobs to complete.
|
||||
// Timeout after 5 seconds.
|
||||
tasksDone := make(chan struct{})
|
||||
go func() {
|
||||
eng.tasks.Wait()
|
||||
close(tasksDone)
|
||||
}()
|
||||
select {
|
||||
case <-time.After(time.Second * 5):
|
||||
case <-tasksDone:
|
||||
}
|
||||
|
||||
// Call shutdown handlers, if any.
|
||||
// Timeout after 15 seconds.
|
||||
// Timeout after 10 seconds.
|
||||
var wg sync.WaitGroup
|
||||
for _, h := range eng.onShutdown {
|
||||
wg.Add(1)
|
||||
|
@ -183,7 +192,7 @@ func (eng *Engine) Shutdown() {
|
|||
close(done)
|
||||
}()
|
||||
select {
|
||||
case <-time.After(time.Second * 15):
|
||||
case <-time.After(time.Second * 10):
|
||||
case <-done:
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue