Skip to content

Commit

Permalink
Move "wait" to daemon/wait.go
Browse files Browse the repository at this point in the history
This is part of an effort to break apart the deprecated server/ package

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <[email protected]> (github: shykes)
  • Loading branch information
Solomon Hykes authored and tiborvass committed Aug 1, 2014
1 parent bd54a73 commit c4ce396
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
3 changes: 3 additions & 0 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
20 changes: 20 additions & 0 deletions daemon/wait.go
Original file line number Diff line number Diff line change
@@ -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)
}
13 changes: 0 additions & 13 deletions server/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c4ce396

Please sign in to comment.