From 93779cc7fee4ee0690d9dd28eed478a418e79577 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 1 Apr 2014 00:11:17 +0000 Subject: [PATCH] Send sigterm and wait forever Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- runtime/container.go | 1 - runtime/runtime.go | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/runtime/container.go b/runtime/container.go index ed68fd0844..bd4a6f2bea 100644 --- a/runtime/container.go +++ b/runtime/container.go @@ -915,7 +915,6 @@ func (container *Container) Stop(seconds int) error { // 1. Send a SIGTERM if err := container.KillSig(15); err != nil { - utils.Debugf("Error sending kill SIGTERM: %s", err) log.Print("Failed to send SIGTERM to the process, force killing") if err := container.KillSig(9); err != nil { return err diff --git a/runtime/runtime.go b/runtime/runtime.go index d5c1a96ada..9e8323279e 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -797,13 +797,18 @@ func (runtime *Runtime) shutdown() error { group := sync.WaitGroup{} utils.Debugf("starting clean shutdown of all containers...") for _, container := range runtime.List() { - if container.State.IsRunning() { - utils.Debugf("stopping %s", container.ID) + c := container + if c.State.IsRunning() { + utils.Debugf("stopping %s", c.ID) group.Add(1) go func() { defer group.Done() - container.Stop(10) + if err := c.KillSig(15); err != nil { + utils.Debugf("kill 15 error for %s - %s", c.ID, err) + } + c.Wait() + utils.Debugf("container stopped %s", c.ID) }() } }