diff --git a/api/server/server.go b/api/server/server.go index d4f445b936..d40413a4e8 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -837,12 +837,19 @@ func postContainersRestart(eng *engine.Engine, version version.Version, w http.R if vars == nil { return fmt.Errorf("Missing parameter") } - job := eng.Job("restart", vars["name"]) - job.Setenv("t", r.Form.Get("t")) - if err := job.Run(); err != nil { + + s, err := strconv.Atoi(r.Form.Get("t")) + if err != nil { return err } + + d := getDaemon(eng) + if err := d.ContainerRestart(vars["name"], s); err != nil { + return err + } + w.WriteHeader(http.StatusNoContent) + return nil } diff --git a/daemon/daemon.go b/daemon/daemon.go index 6f50dc9f3c..959907d592 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -120,7 +120,6 @@ func (daemon *Daemon) Install(eng *engine.Engine) error { for name, method := range map[string]engine.Handler{ "container_inspect": daemon.ContainerInspect, "info": daemon.CmdInfo, - "restart": daemon.ContainerRestart, "execCreate": daemon.ContainerExecCreate, "execStart": daemon.ContainerExecStart, } { diff --git a/daemon/restart.go b/daemon/restart.go index 1bd2f8ca10..86cc97d7e7 100644 --- a/daemon/restart.go +++ b/daemon/restart.go @@ -1,27 +1,13 @@ package daemon -import ( - "fmt" +import "fmt" - "github.com/docker/docker/engine" -) - -func (daemon *Daemon) ContainerRestart(job *engine.Job) error { - if len(job.Args) != 1 { - return fmt.Errorf("Usage: %s CONTAINER\n", job.Name) - } - var ( - name = job.Args[0] - t = 10 - ) - if job.EnvExists("t") { - t = job.GetenvInt("t") - } +func (daemon *Daemon) ContainerRestart(name string, seconds int) error { container, err := daemon.Get(name) if err != nil { return err } - if err := container.Restart(int(t)); err != nil { + if err := container.Restart(seconds); err != nil { return fmt.Errorf("Cannot restart container %s: %s\n", name, err) } container.LogEvent("restart")