[#389686] Add crash detection logic to daemon

This commit is contained in:
Dane Everitt
2019-11-30 16:43:18 -08:00
parent be14811eb4
commit 8c57583ce9
6 changed files with 125 additions and 7 deletions

View File

@@ -316,6 +316,17 @@ func (d *DockerEnvironment) Terminate(signal os.Signal) error {
)
}
// Determine the container exit state and return the exit code and wether or not
// the container was killed by the OOM killer.
func (d *DockerEnvironment) ExitState() (uint32, bool, error) {
c, err := d.Client.ContainerInspect(context.Background(), d.Server.Uuid)
if err != nil {
return 0, false, errors.WithStack(err)
}
return uint32(c.State.ExitCode), c.State.OOMKilled, nil
}
// Attaches to the docker container itself and ensures that we can pipe data in and out
// of the process stream. This should not be used for reading console data as you *will*
// miss important output at the beginning because of the time delay with attaching to the