in pkg/problemdetector/problem_detector.go [47:88]
func (p *problemDetector) Run(termCh <-chan error) error {
// Start the log monitors one by one.
var chans []<-chan *types.Status
failureCount := 0
for _, m := range p.monitors {
ch, err := m.Start()
if err != nil {
// Do not return error and keep on trying the following config files.
glog.Errorf("Failed to start problem daemon %v: %v", m, err)
failureCount++
continue
}
if ch != nil {
chans = append(chans, ch)
}
}
allMonitors := p.monitors
if len(allMonitors) == failureCount {
return fmt.Errorf("no problem daemon is successfully setup")
}
defer func() {
for _, m := range allMonitors {
m.Stop()
}
}()
ch := groupChannel(chans)
glog.Info("Problem detector started")
for {
select {
case <-termCh:
return nil
case status := <-ch:
for _, exporter := range p.exporters {
exporter.ExportProblems(status)
}
}
}
}