+15
-1
@@ -30,7 +30,21 @@ func (s *server) services(ctx context.Context) []*homelabv1.Service {
|
||||
if s.mockSvcs != nil {
|
||||
return s.mockSvcs
|
||||
}
|
||||
return append(s.systemdServices(ctx), s.dockerServices(ctx)...)
|
||||
svcs := append(s.systemdServices(ctx), s.dockerServices(ctx)...)
|
||||
// живые (active/partial) наверх, остальное (inactive, not-found, failed, error) вниз; внутри групп — по имени
|
||||
rank := func(svc *homelabv1.Service) int {
|
||||
if svc.Error == "" && (svc.State == "active" || svc.State == "partial") {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
sort.SliceStable(svcs, func(i, j int) bool {
|
||||
if ri, rj := rank(svcs[i]), rank(svcs[j]); ri != rj {
|
||||
return ri < rj
|
||||
}
|
||||
return svcs[i].Name < svcs[j].Name
|
||||
})
|
||||
return svcs
|
||||
}
|
||||
|
||||
// logProbeChange logs poll-path probe failures once per change: the poll repeats every 3s per client,
|
||||
|
||||
Reference in New Issue
Block a user