Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Output gonit status in alphabetical order.

Change-Id: I3ccec2db14fa77d63e6cb5e1d73fe6dda1f19a54
  • Loading branch information...
commit 5c3a59e8aac1b35c66a168f8d980c97d5f448ac0 1 parent 21ff275
@lisbakke lisbakke authored
Showing with 27 additions and 0 deletions.
  1. +27 −0 api.go
View
27 api.go
@@ -4,6 +4,7 @@ package gonit
import (
"errors"
+ "sort"
"github.com/cloudfoundry/gosigar"
)
@@ -37,6 +38,30 @@ type ProcessGroupStatus struct {
Group []ProcessStatus
}
+func (pgs *ProcessGroupStatus) Len() int {
+ return len(pgs.Group)
+}
+
+func (pgs *ProcessGroupStatus) Less(i, j int) bool {
+ return pgs.Group[i].Summary.Name < pgs.Group[j].Summary.Name
+}
+
+func (pgs *ProcessGroupStatus) Swap(i, j int) {
+ pgs.Group[i], pgs.Group[j] = pgs.Group[j], pgs.Group[i]
+}
+
+func (s *Summary) Len() int {
+ return len(s.Processes)
+}
+
+func (s *Summary) Less(i, j int) bool {
+ return s.Processes[i].Name < s.Processes[j].Name
+}
+
+func (s *Summary) Swap(i, j int) {
+ s.Processes[i], s.Processes[j] = s.Processes[j], s.Processes[i]
+}
+
type Summary struct {
Processes []ProcessSummary
}
@@ -182,6 +207,7 @@ func (c *Control) groupStatus(group *ProcessGroup,
c.processStatus(process, &status)
groupStatus.Group = append(groupStatus.Group, status)
}
+ sort.Sort(groupStatus)
return nil
}
@@ -248,6 +274,7 @@ func (a *API) Summary(unused interface{}, s *Summary) error {
s.Processes = append(s.Processes, summary)
}
}
+ sort.Sort(s)
return nil
}
Please sign in to comment.
Something went wrong with that request. Please try again.