Add healthcheck info to CLI.

Signed-off-by: Dong Chen <dongluo.chen@docker.com>
This commit is contained in:
Dong Chen 2016-07-15 11:05:42 -07:00
parent ef0aa2aeb2
commit 3982f039a2
1 changed files with 13 additions and 0 deletions

View File

@ -54,6 +54,19 @@ func FullStateString(state *types.ContainerState) string {
if state.Restarting {
return fmt.Sprintf("Restarting (%d) %s ago", state.ExitCode, units.HumanDuration(time.Now().UTC().Sub(finishedAt)))
}
// Container is Up. Add Health check info when healthcheck is defined.
healthText := ""
if h := state.Health; h != nil {
switch h.Status {
case types.Starting:
healthText = "health: starting"
default: // Healthy and Unhealthy are clear on their own
healthText = h.Status
}
}
if len(healthText) > 0 {
return fmt.Sprintf("Up %s (%s)", units.HumanDuration(time.Now().UTC().Sub(startedAt)), healthText)
}
return fmt.Sprintf("Up %s", units.HumanDuration(time.Now().UTC().Sub(startedAt)))
}