mirror of https://github.com/docker/docs.git
Add some error checking in container monitor
This commit is contained in:
parent
d17f78c373
commit
69c2250ec2
17
container.go
17
container.go
|
@ -356,7 +356,10 @@ func (container *Container) releaseNetwork() error {
|
||||||
func (container *Container) monitor() {
|
func (container *Container) monitor() {
|
||||||
// Wait for the program to exit
|
// Wait for the program to exit
|
||||||
Debugf("Waiting for process")
|
Debugf("Waiting for process")
|
||||||
container.cmd.Wait()
|
if err := container.cmd.Wait(); err != nil {
|
||||||
|
// Discard the error as any signals or non 0 returns will generate an error
|
||||||
|
Debugf("%s: Process: %s", container.Id, err)
|
||||||
|
}
|
||||||
Debugf("Process finished")
|
Debugf("Process finished")
|
||||||
|
|
||||||
exitCode := container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
|
exitCode := container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
|
||||||
|
@ -365,8 +368,12 @@ func (container *Container) monitor() {
|
||||||
if err := container.releaseNetwork(); err != nil {
|
if err := container.releaseNetwork(); err != nil {
|
||||||
log.Printf("%v: Failed to release network: %v", container.Id, err)
|
log.Printf("%v: Failed to release network: %v", container.Id, err)
|
||||||
}
|
}
|
||||||
container.stdout.Close()
|
if err := container.stdout.Close(); err != nil {
|
||||||
container.stderr.Close()
|
Debugf("%s: Error close stdout: %s", container.Id, err)
|
||||||
|
}
|
||||||
|
if err := container.stderr.Close(); err != nil {
|
||||||
|
Debugf("%s: Error close stderr: %s", container.Id, err)
|
||||||
|
}
|
||||||
if err := container.Unmount(); err != nil {
|
if err := container.Unmount(); err != nil {
|
||||||
log.Printf("%v: Failed to umount filesystem: %v", container.Id, err)
|
log.Printf("%v: Failed to umount filesystem: %v", container.Id, err)
|
||||||
}
|
}
|
||||||
|
@ -378,7 +385,9 @@ func (container *Container) monitor() {
|
||||||
|
|
||||||
// Report status back
|
// Report status back
|
||||||
container.State.setStopped(exitCode)
|
container.State.setStopped(exitCode)
|
||||||
container.ToDisk()
|
if err := container.ToDisk(); err != nil {
|
||||||
|
log.Printf("%s: Failed to dump configuration to the disk: %s", container.Id, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) kill() error {
|
func (container *Container) kill() error {
|
||||||
|
|
Loading…
Reference in New Issue