Remove job from stop

Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
Antonio Murdaca 2015-04-12 00:41:16 +02:00
parent e3dd323336
commit 04cc6c6aa4
3 changed files with 12 additions and 21 deletions

View file

@ -988,9 +988,14 @@ func postContainersStop(eng *engine.Engine, version version.Version, w http.Resp
if vars == nil {
return fmt.Errorf("Missing parameter")
}
job := eng.Job("stop", vars["name"])
job.Setenv("t", r.Form.Get("t"))
if err := job.Run(); err != nil {
d := getDaemon(eng)
seconds, err := strconv.Atoi(r.Form.Get("t"))
if err != nil {
return err
}
if err := d.ContainerStop(vars["name"], seconds); err != nil {
if err.Error() == "Container already stopped" {
w.WriteHeader(http.StatusNotModified)
return nil
@ -998,6 +1003,7 @@ func postContainersStop(eng *engine.Engine, version version.Version, w http.Resp
return err
}
w.WriteHeader(http.StatusNoContent)
return nil
}

View file

@ -126,7 +126,6 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
"logs": daemon.ContainerLogs,
"restart": daemon.ContainerRestart,
"start": daemon.ContainerStart,
"stop": daemon.ContainerStop,
"execCreate": daemon.ContainerExecCreate,
"execStart": daemon.ContainerExecStart,
"execInspect": daemon.ContainerExecInspect,

View file

@ -1,22 +1,8 @@
package daemon
import (
"fmt"
import "fmt"
"github.com/docker/docker/engine"
)
func (daemon *Daemon) ContainerStop(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) ContainerStop(name string, seconds int) error {
container, err := daemon.Get(name)
if err != nil {
return err
@ -24,7 +10,7 @@ func (daemon *Daemon) ContainerStop(job *engine.Job) error {
if !container.IsRunning() {
return fmt.Errorf("Container already stopped")
}
if err := container.Stop(int(t)); err != nil {
if err := container.Stop(seconds); err != nil {
return fmt.Errorf("Cannot stop container %s: %s\n", name, err)
}
container.LogEvent("stop")