mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
63bd4ad9d6
This is part of an effort to break apart the deprecated server/ package Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package daemon
|
|
|
|
import (
|
|
"github.com/docker/docker/engine"
|
|
)
|
|
|
|
func (daemon *Daemon) ContainerPause(job *engine.Job) engine.Status {
|
|
if len(job.Args) != 1 {
|
|
return job.Errorf("Usage: %s CONTAINER", job.Name)
|
|
}
|
|
name := job.Args[0]
|
|
container := daemon.Get(name)
|
|
if container == nil {
|
|
return job.Errorf("No such container: %s", name)
|
|
}
|
|
if err := container.Pause(); err != nil {
|
|
return job.Errorf("Cannot pause container %s: %s", name, err)
|
|
}
|
|
job.Eng.Job("log", "pause", container.ID, daemon.Repositories().ImageName(container.Image)).Run()
|
|
return engine.StatusOK
|
|
}
|
|
|
|
func (daemon *Daemon) ContainerUnpause(job *engine.Job) engine.Status {
|
|
if n := len(job.Args); n < 1 || n > 2 {
|
|
return job.Errorf("Usage: %s CONTAINER", job.Name)
|
|
}
|
|
name := job.Args[0]
|
|
container := daemon.Get(name)
|
|
if container == nil {
|
|
return job.Errorf("No such container: %s", name)
|
|
}
|
|
if err := container.Unpause(); err != nil {
|
|
return job.Errorf("Cannot unpause container %s: %s", name, err)
|
|
}
|
|
job.Eng.Job("log", "unpause", container.ID, daemon.Repositories().ImageName(container.Image)).Run()
|
|
return engine.StatusOK
|
|
}
|