From c4ce396f461a75ab887f3e1a2dcc54b10fc20423 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 31 Jul 2014 20:50:46 +0000 Subject: [PATCH] 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 (github: shykes) --- daemon/daemon.go | 3 +++ daemon/wait.go | 20 ++++++++++++++++++++ server/container.go | 13 ------------- server/init.go | 1 - 4 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 daemon/wait.go 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,