зеркало из https://github.com/microsoft/docker.git
Remove job from stop
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
Родитель
e3dd323336
Коммит
04cc6c6aa4
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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")
|
||||
|
|
Загрузка…
Ссылка в новой задаче