diff --git a/service.go b/service.go index 8c9734f..c8c56f0 100644 --- a/service.go +++ b/service.go @@ -12,8 +12,8 @@ type Service interface { Start(ctx context.Context, logger *log.Logger) error // Stop stops the service. It should block until the service is cleaned up. Stop(ctx context.Context) error - // Health returns the health status of the service. - Health() error + // Status returns the current status and health of the service. + Status() (string, error) } // Reloader defines an optional interface for services that support configuration reloading. diff --git a/starter.go b/starter.go index 7b9cfb2..0d7b23f 100644 --- a/starter.go +++ b/starter.go @@ -367,11 +367,16 @@ func getInternalStatus() string { for _, p := range priorities { for _, ms := range services[p] { - status := shell.Green("OK") - if err := ms.svc.Health(); err != nil { - status = shell.Red(fmt.Sprintf("FAIL (%v)", err)) + statusMsg, err := ms.svc.Status() + indicator := shell.Green("OK") + if err != nil { + indicator = shell.Red(fmt.Sprintf("FAIL (%v)", err)) + } + if statusMsg != "" { + out += fmt.Sprintf("[%d] %-20s %s (%s)\n", p, ms.Name, indicator, statusMsg) + } else { + out += fmt.Sprintf("[%d] %-20s %s\n", p, ms.Name, indicator) } - out += fmt.Sprintf("[%d] %-20s %s\n", p, ms.Name, status) } } return out