Skip to content
Snippets Groups Projects
Commit 40b80af3 authored by Josh Brooks's avatar Josh Brooks
Browse files

Add a debug GetRunningProcesses to bindings

parent 492b1a40
No related branches found
No related tags found
3 merge requests!510Release,!381Initial CTIDH,!378Add a debug GetRunningProcesses to bindings
...@@ -136,6 +136,12 @@ func (c *Cmix) IsHealthy() bool { ...@@ -136,6 +136,12 @@ func (c *Cmix) IsHealthy() bool {
return c.api.GetCmix().IsHealthy() 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 // NetworkHealthCallback contains a callback that is used to receive
// notification if network health changes. // notification if network health changes.
type NetworkHealthCallback interface { type NetworkHealthCallback interface {
......
...@@ -61,10 +61,13 @@ func (m *Multi) GetStatus() Status { ...@@ -61,10 +61,13 @@ func (m *Multi) GetStatus() Status {
lowestStatus := Stopped lowestStatus := Stopped
m.mux.RLock() m.mux.RLock()
for _, s := range m.stoppables { for i := range m.stoppables {
s := m.stoppables[i]
status := s.GetStatus() status := s.GetStatus()
if status < lowestStatus { if status < lowestStatus {
lowestStatus = status lowestStatus = status
jww.DEBUG.Printf("Stoppable %s has status %s",
s.Name(), status.String())
} }
} }
...@@ -73,6 +76,24 @@ func (m *Multi) GetStatus() Status { ...@@ -73,6 +76,24 @@ func (m *Multi) GetStatus() Status {
return lowestStatus 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. // IsRunning returns true if Stoppable is marked as running.
func (m *Multi) IsRunning() bool { func (m *Multi) IsRunning() bool {
return m.GetStatus() == Running return m.GetStatus() == Running
...@@ -90,7 +111,7 @@ func (m *Multi) IsStopped() bool { ...@@ -90,7 +111,7 @@ func (m *Multi) IsStopped() bool {
// Close issues a close signal to all child stoppables and marks the status of // 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 // 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. // assumes they print them to the log.
func (m *Multi) Close() error { func (m *Multi) Close() error {
var numErrors uint32 var numErrors uint32
......
...@@ -397,6 +397,12 @@ func (c *Cmix) HasRunningProcessies() bool { ...@@ -397,6 +397,12 @@ func (c *Cmix) HasRunningProcessies() bool {
return !c.followerServices.stoppable.IsStopped() 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. // GetRoundEvents registers a callback for round events.
func (c *Cmix) GetRoundEvents() interfaces.RoundEvents { func (c *Cmix) GetRoundEvents() interfaces.RoundEvents {
jww.INFO.Printf("GetRoundEvents()") jww.INFO.Printf("GetRoundEvents()")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment