2015-05-02 01:03:35 +00:00
|
|
|
package daemon
|
|
|
|
|
2015-09-16 18:56:26 +00:00
|
|
|
import (
|
2015-09-17 18:54:14 +00:00
|
|
|
derr "github.com/docker/docker/errors"
|
2015-09-16 18:56:26 +00:00
|
|
|
)
|
2015-05-02 01:03:35 +00:00
|
|
|
|
|
|
|
// ContainerUnpause unpauses a container
|
2015-09-29 17:51:40 +00:00
|
|
|
func (daemon *Daemon) ContainerUnpause(name string) error {
|
|
|
|
container, err := daemon.Get(name)
|
2015-05-02 01:03:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2015-11-02 23:39:39 +00:00
|
|
|
if err := daemon.containerUnpause(container); err != nil {
|
2015-09-16 18:56:26 +00:00
|
|
|
return derr.ErrorCodeCantUnpause.WithArgs(name, err)
|
2015-05-02 01:03:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2015-11-02 23:39:39 +00:00
|
|
|
|
|
|
|
// containerUnpause resumes the container execution after the container is paused.
|
|
|
|
func (daemon *Daemon) containerUnpause(container *Container) error {
|
|
|
|
container.Lock()
|
|
|
|
defer container.Unlock()
|
|
|
|
|
|
|
|
// We cannot unpause the container which is not running
|
|
|
|
if !container.Running {
|
|
|
|
return derr.ErrorCodeNotRunning.WithArgs(container.ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
// We cannot unpause the container which is not paused
|
|
|
|
if !container.Paused {
|
|
|
|
return derr.ErrorCodeNotPaused.WithArgs(container.ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := daemon.execDriver.Unpause(container.command); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
container.Paused = false
|
2015-11-03 17:33:13 +00:00
|
|
|
daemon.LogContainerEvent(container, "unpause")
|
2015-11-02 23:39:39 +00:00
|
|
|
return nil
|
|
|
|
}
|