diff --git a/bindings/follow.go b/bindings/follow.go index 2303274e3c51e897c2331faed61dd56f4d939f71..e9b5097619217648d9d9d4bc38e4d159fdbe98a4 100644 --- a/bindings/follow.go +++ b/bindings/follow.go @@ -136,6 +136,12 @@ func (c *Cmix) IsHealthy() bool { return c.api.GetCmix().IsHealthy() } +// GetRunningProcesses returns the name of all running processes at the time +// of this call. +func (c *Cmix) GetRunningProcesses() []string { + return c.api.GetRunningProcesses() +} + // NetworkHealthCallback contains a callback that is used to receive // notification if network health changes. type NetworkHealthCallback interface { diff --git a/stoppable/multi.go b/stoppable/multi.go index 81bd270257b19fd3a6d75c78591b390335230d2b..7e8027fa50daa90372594921ad583b758cacf8b0 100644 --- a/stoppable/multi.go +++ b/stoppable/multi.go @@ -61,10 +61,13 @@ func (m *Multi) GetStatus() Status { lowestStatus := Stopped m.mux.RLock() - for _, s := range m.stoppables { + for i := range m.stoppables { + s := m.stoppables[i] status := s.GetStatus() if status < lowestStatus { lowestStatus = status + jww.DEBUG.Printf("Stoppable %s has status %s", + s.Name(), status.String()) } } @@ -73,6 +76,24 @@ func (m *Multi) GetStatus() Status { return lowestStatus } +// GetRunningProcesses returns a list of running Stoppable processes. +func (m *Multi) GetRunningProcesses() []string { + m.mux.RLock() + + runningProcesses := make([]string, 0) + for i := range m.stoppables { + s := m.stoppables[i] + status := s.GetStatus() + if status < Stopped { + runningProcesses = append(runningProcesses, s.Name()) + } + } + + m.mux.RUnlock() + + return runningProcesses +} + // IsRunning returns true if Stoppable is marked as running. func (m *Multi) IsRunning() bool { return m.GetStatus() == Running @@ -90,7 +111,7 @@ func (m *Multi) IsStopped() bool { // Close issues a close signal to all child stoppables and marks the status of // the Multi Stoppable as stopping. Returns an error if one or more child -// stoppables failed to close but it does not return their specific errors and +// stoppables failed to close, but it does not return their specific errors and // assumes they print them to the log. func (m *Multi) Close() error { var numErrors uint32 diff --git a/xxdk/cmix.go b/xxdk/cmix.go index 33658c752d3242de2f7ae1606e14d6babfb52e99..b3f5e5bd42f3341553c1d57b3484ea6efa485bf5 100644 --- a/xxdk/cmix.go +++ b/xxdk/cmix.go @@ -397,6 +397,12 @@ func (c *Cmix) HasRunningProcessies() bool { return !c.followerServices.stoppable.IsStopped() } +// GetRunningProcesses returns the name of all running processes at the time +// of this call. +func (c *Cmix) GetRunningProcesses() []string { + return c.followerServices.stoppable.GetRunningProcesses() +} + // GetRoundEvents registers a callback for round events. func (c *Cmix) GetRoundEvents() interfaces.RoundEvents { jww.INFO.Printf("GetRoundEvents()")