diff --git a/daemon/daemon.go b/daemon/daemon.go index 08e710b1c8..5f497454ab 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -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 } diff --git a/daemon/wait.go b/daemon/wait.go new file mode 100644 index 0000000000..7224b6231f --- /dev/null +++ b/daemon/wait.go @@ -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) +} diff --git a/server/container.go b/server/container.go index f8476e5c0a..ac02ad7a5a 100644 --- a/server/container.go +++ b/server/container.go @@ -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) diff --git a/server/init.go b/server/init.go index 31c9e0419d..914f53d6b7 100644 --- a/server/init.go +++ b/server/init.go @@ -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,