1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Send sigterm and wait forever

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-04-01 00:11:17 +00:00
parent e36d89b0f9
commit 93779cc7fe
2 changed files with 8 additions and 4 deletions

View file

@ -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

View file

@ -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)
}()
}
}