feat: refactor Service interface to replace Health() with Status() (string, error) for human-readable diagnostics (by AI)
This commit is contained in:
parent
674ec88117
commit
4bf0ed1d4e
@ -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.
|
||||
|
||||
13
starter.go
13
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user