wip: using pflag and viper; remove go routine for exec file search

This commit is contained in:
2024-03-21 11:26:11 +11:00
parent a1d0360d46
commit 6032b6c0c1
9 changed files with 100 additions and 606 deletions
+4 -5
View File
@@ -24,7 +24,7 @@ var (
crontabScheduleRegex = regexp.MustCompile(CrontabScheduleRegexPattern)
)
func readConfigYaml(path, name, format string) ([]ServiceTask, []CronTask, *FindUtils, error) {
func readConfigYaml(path, name, format string) ([]ServiceTask, []CronTask, error) {
var (
err error
nameMap map[string]any
@@ -34,7 +34,7 @@ func readConfigYaml(path, name, format string) ([]ServiceTask, []CronTask, *Find
item any
services []ServiceTask
crones []CronTask
findUtils *FindUtils
//findUtils *FindUtils
)
viper.AddConfigPath(path)
@@ -42,10 +42,9 @@ func readConfigYaml(path, name, format string) ([]ServiceTask, []CronTask, *Find
viper.SetConfigName(name)
if err = viper.ReadInConfig(); err != nil {
return nil, nil, nil, fmt.Errorf("reading config in dir %s, file %s, format %s: %w", path, name, format, err)
return nil, nil, fmt.Errorf("reading config in dir %s, file %s, format %s: %w", path, name, format, err)
}
findUtils = startFindUtils()
services = make([]ServiceTask, 0)
nameMap = viper.GetStringMap(ServiceConfigGroup)
for itemName, item = range nameMap {
@@ -74,7 +73,7 @@ func readConfigYaml(path, name, format string) ([]ServiceTask, []CronTask, *Find
crones = append(crones, cronTask)
}
return services, crones, findUtils, nil
return services, crones, nil
}
func parseYamlSchedule(input string) (schedule CronSchedule, err error) {