Provide a way to get status now
This commit is contained in:
parent
444cc59250
commit
9fbc88a60f
@ -24,6 +24,22 @@ type monitor struct {
|
|||||||
services map[string]*Status
|
services map[string]*Status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *monitor) Check(service string) error {
|
||||||
|
status, err := m.check(service)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.Lock()
|
||||||
|
m.services[service] = status
|
||||||
|
m.Unlock()
|
||||||
|
|
||||||
|
if status.Code != StatusRunning {
|
||||||
|
return errors.New(status.Info)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// check provides binary running/failed status.
|
// check provides binary running/failed status.
|
||||||
// In the event Debug.Health cannot be called on a service we reap the node.
|
// In the event Debug.Health cannot be called on a service we reap the node.
|
||||||
func (m *monitor) check(service string) (*Status, error) {
|
func (m *monitor) check(service string) (*Status, error) {
|
||||||
|
@ -17,6 +17,8 @@ type StatusCode int
|
|||||||
type Monitor interface {
|
type Monitor interface {
|
||||||
// Reap a service and stop monitoring
|
// Reap a service and stop monitoring
|
||||||
Reap(service string) error
|
Reap(service string) error
|
||||||
|
// Check the status of the service now
|
||||||
|
Check(service string) error
|
||||||
// Status of the service
|
// Status of the service
|
||||||
Status(service string) (Status, error)
|
Status(service string) (Status, error)
|
||||||
// Watch starts watching the service
|
// Watch starts watching the service
|
||||||
|
Loading…
Reference in New Issue
Block a user