Restart() implementation

Upstream-commit: f0c08b57abb6e273b54b3f6d253acfe7b0107972
Component: engine
This commit is contained in:
Andrea Luzzardi
2013-01-22 15:03:40 -08:00
parent 37ddcb4a4a
commit 47356dc54b
+13 -2
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()