1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Restart() implementation

This commit is contained in:
Andrea Luzzardi 2013-01-22 15:03:40 -08:00
parent 64fc86fba7
commit f0c08b57ab

View file

@ -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()