Refactor status module initialization: register runtime privider as soon as possible
This commit is contained in:
@@ -35,10 +35,6 @@ func (s *Status) Manager() *mgr.Manager {
|
|||||||
|
|
||||||
// Start starts the module.
|
// Start starts the module.
|
||||||
func (s *Status) Start() error {
|
func (s *Status) Start() error {
|
||||||
if err := s.setupRuntimeProvider(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
s.mgr.Go("status publisher", s.statusPublisher)
|
s.mgr.Go("status publisher", s.statusPublisher)
|
||||||
|
|
||||||
s.instance.NetEnv().EventOnlineStatusChange.AddCallback("update online status in system status",
|
s.instance.NetEnv().EventOnlineStatusChange.AddCallback("update online status in system status",
|
||||||
@@ -67,6 +63,14 @@ func (s *Status) Stop() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Status) prep() error {
|
||||||
|
// register status provider as soon as possible
|
||||||
|
if err := s.setupRuntimeProvider(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// AddToDebugInfo adds the system status to the given debug.Info.
|
// AddToDebugInfo adds the system status to the given debug.Info.
|
||||||
func AddToDebugInfo(di *debug.Info) {
|
func AddToDebugInfo(di *debug.Info) {
|
||||||
di.AddSection(
|
di.AddSection(
|
||||||
@@ -96,6 +100,10 @@ func New(instance instance) (*Status, error) {
|
|||||||
notifications: make(map[string]map[string]*notifications.Notification),
|
notifications: make(map[string]map[string]*notifications.Notification),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := module.prep(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return module, nil
|
return module, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user