|
|
|
@ -153,6 +153,34 @@ func (c *Components) Init(context *cli.Context) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *Components) Stop() error {
|
|
|
|
|
// Sort Components by Priority DESC
|
|
|
|
|
components := make([]Component, len(c.components))
|
|
|
|
|
for _, com := range c.components {
|
|
|
|
|
components = append(components, com)
|
|
|
|
|
}
|
|
|
|
|
sort.SliceStable(components, func(i, j int) bool {
|
|
|
|
|
if components[i] == nil || components[j] == nil {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return components[i].Priority() > components[j].Priority()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Init them sorted now
|
|
|
|
|
for _, component := range components {
|
|
|
|
|
if c == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := component.Stop(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *Components) Health(context context.Context) HealthInfoMap {
|
|
|
|
|
result := make(HealthInfoMap, len(c.components))
|
|
|
|
|
|
|
|
|
|