mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Restart() implementation
This commit is contained in:
parent
64fc86fba7
commit
f0c08b57ab
1 changed files with 13 additions and 2 deletions
15
container.go
15
container.go
|
@ -172,10 +172,10 @@ func (container *Container) StderrPipe() (io.ReadCloser, error) {
|
|||
}
|
||||
|
||||
func (container *Container) monitor() {
|
||||
// Wait for the program to exit
|
||||
container.cmd.Wait()
|
||||
exitCode := container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
|
||||
|
||||
// Cleanup container
|
||||
// Cleanup
|
||||
container.stdout.Close()
|
||||
container.stderr.Close()
|
||||
if err := container.Filesystem.Umount(); err != nil {
|
||||
|
@ -183,6 +183,7 @@ func (container *Container) monitor() {
|
|||
}
|
||||
|
||||
// Report status back
|
||||
exitCode := container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
|
||||
container.State.setStopped(exitCode)
|
||||
container.save()
|
||||
}
|
||||
|
@ -229,6 +230,16 @@ func (container *Container) Stop() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (container *Container) Restart() error {
|
||||
if err := container.Stop(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (container *Container) Wait() {
|
||||
for container.State.Running {
|
||||
container.State.wait()
|
||||
|
|
Loading…
Reference in a new issue