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

Move "wait" to daemon/wait.go

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)
This commit is contained in:
Solomon Hykes 2014-07-31 20:50:46 +00:00 committed by Tibor Vass
parent bd54a73c42
commit c4ce396f46
4 changed files with 23 additions and 14 deletions

View file

@ -135,6 +135,9 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
if err := eng.Register("restart", daemon.ContainerRestart); err != nil {
return err
}
if err := eng.Register("wait", daemon.ContainerWait); err != nil {
return err
}
return nil
}

20
daemon/wait.go Normal file
View file

@ -0,0 +1,20 @@
package daemon
import (
"time"
"github.com/docker/docker/engine"
)
func (daemon *Daemon) ContainerWait(job *engine.Job) engine.Status {
if len(job.Args) != 1 {
return job.Errorf("Usage: %s", job.Name)
}
name := job.Args[0]
if container := daemon.Get(name); container != nil {
status, _ := container.State.WaitStop(-1 * time.Second)
job.Printf("%d\n", status)
return engine.StatusOK
}
return job.Errorf("%s: no such container: %s", job.Name, name)
}

View file

@ -386,19 +386,6 @@ func (srv *Server) ContainerDestroy(job *engine.Job) engine.Status {
return engine.StatusOK
}
func (srv *Server) ContainerWait(job *engine.Job) engine.Status {
if len(job.Args) != 1 {
return job.Errorf("Usage: %s", job.Name)
}
name := job.Args[0]
if container := srv.daemon.Get(name); container != nil {
status, _ := container.State.WaitStop(-1 * time.Second)
job.Printf("%d\n", status)
return engine.StatusOK
}
return job.Errorf("%s: no such container: %s", job.Name, name)
}
func (srv *Server) ContainerResize(job *engine.Job) engine.Status {
if len(job.Args) != 3 {
return job.Errorf("Not enough arguments. Usage: %s CONTAINER HEIGHT WIDTH\n", job.Name)

View file

@ -86,7 +86,6 @@ func InitServer(job *engine.Job) engine.Status {
job.Eng.Hack_SetGlobalVar("httpapi.daemon", srv.daemon)
for name, handler := range map[string]engine.Handler{
"wait": srv.ContainerWait,
"tag": srv.ImageTag, // FIXME merge with "image_tag"
"resize": srv.ContainerResize,
"commit": srv.ContainerCommit,