func (s *ServiceManager) loadAllServices() { descList := queue_info.GetServiceDescriptions() if len(descList) > 0 { s.serviceIdCounter = descList[len(descList)-1].ExportId } for _, desc := range descList { if _, ok := s.allSvcs[desc.Name]; ok { log.Warning("Service with the same name detected: %s", desc.Name) } if svc, ok := s.loadService(desc); ok { s.allSvcs[desc.Name] = svc } } for _, svc := range s.allSvcs { svc.StartUpdate() } }
func extractLogFiles(items []os.FileInfo) BinaryLogs { candidates := BinaryLogs{} for _, item := range items { if item.IsDir() { continue } name := item.Name() if strings.Index(name, BinaryLogNamePrefix) == 0 { chunks := strings.SplitN(name, BinaryLogNamePrefix, 2) chunks = strings.SplitN(chunks[1], BinaryLogFileExt, 2) num, err := strconv.Atoi(chunks[0]) if err != nil { log.Warning("File matches binary log naming pattern, please remove it: %s", item.Name()) continue } candidates = append(candidates, &BinLogFile{name, num}) } } sort.Sort(candidates) return candidates }
func (s *ServiceManager) loadService(desc *queue_info.ServiceDescription) (apis.ISvc, bool) { if desc.Disabled { log.Error("Service is disabled. Skipping: %s", desc.Name) return nil, false } if desc.ToDelete { log.Warning("Service should be deleted: %s", desc.Name) queue_info.DeleteServiceData(desc.Name) return nil, false } log.Debug("Loading service data for: %s", desc.Name) serviceLoader, ok := GetServiceLoader(desc.SType) if !ok { log.Error("Unknown service '%s' type: %s", desc.Name, desc.SType) return nil, false } svcInstance, err := serviceLoader(s, desc) if err != nil { log.Error("Service '%s' was not loaded because of: %s", desc.Name, err) return nil, false } return svcInstance, true }