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

Merge pull request #12350 from runcom/remove-job-restart

Remove job from restart
This commit is contained in:
Alexander Morozov 2015-04-16 10:27:43 -07:00
commit 5224151da9
3 changed files with 13 additions and 21 deletions

View file

@ -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
}

View file

@ -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,
} {

View file

@ -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")