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:
commit
5224151da9
3 changed files with 13 additions and 21 deletions
|
@ -837,12 +837,19 @@ func postContainersRestart(eng *engine.Engine, version version.Version, w http.R
|
||||||
if vars == nil {
|
if vars == nil {
|
||||||
return fmt.Errorf("Missing parameter")
|
return fmt.Errorf("Missing parameter")
|
||||||
}
|
}
|
||||||
job := eng.Job("restart", vars["name"])
|
|
||||||
job.Setenv("t", r.Form.Get("t"))
|
s, err := strconv.Atoi(r.Form.Get("t"))
|
||||||
if err := job.Run(); err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d := getDaemon(eng)
|
||||||
|
if err := d.ContainerRestart(vars["name"], s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,6 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
|
||||||
for name, method := range map[string]engine.Handler{
|
for name, method := range map[string]engine.Handler{
|
||||||
"container_inspect": daemon.ContainerInspect,
|
"container_inspect": daemon.ContainerInspect,
|
||||||
"info": daemon.CmdInfo,
|
"info": daemon.CmdInfo,
|
||||||
"restart": daemon.ContainerRestart,
|
|
||||||
"execCreate": daemon.ContainerExecCreate,
|
"execCreate": daemon.ContainerExecCreate,
|
||||||
"execStart": daemon.ContainerExecStart,
|
"execStart": daemon.ContainerExecStart,
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -1,27 +1,13 @@
|
||||||
package daemon
|
package daemon
|
||||||
|
|
||||||
import (
|
import "fmt"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/docker/docker/engine"
|
func (daemon *Daemon) ContainerRestart(name string, seconds int) error {
|
||||||
)
|
|
||||||
|
|
||||||
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")
|
|
||||||
}
|
|
||||||
container, err := daemon.Get(name)
|
container, err := daemon.Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
return fmt.Errorf("Cannot restart container %s: %s\n", name, err)
|
||||||
}
|
}
|
||||||
container.LogEvent("restart")
|
container.LogEvent("restart")
|
||||||
|
|
Loading…
Reference in a new issue