Shut down containers when force stopping the runtime

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #68
Approved by: rhatdan
This commit is contained in:
Matthew Heon
2017-11-28 11:26:06 -05:00
committed by Atomic Bot
parent 0e3dd5f687
commit 4f8fe2b810

View File

@ -211,6 +211,20 @@ func (r *Runtime) Shutdown(force bool) error {
r.valid = false
// Shutdown all containers if --force is given
if force {
ctrs, err := r.state.AllContainers()
if err !=nil {
logrus.Errorf("Error retrieving containers from database: %v", err)
} else {
for _, ctr := range ctrs {
if err := ctr.Stop(ctrRemoveTimeout); err != nil {
logrus.Errorf("Error stopping container %s: %v", ctr.ID(), err)
}
}
}
}
_, err := r.store.Shutdown(force)
if err != nil {
return err