mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Remove job from restart
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
parent
17ef617c77
commit
e41192a3f8
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 {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
} {
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue