ferry/pkg/service/task.go

25 lines
465 B
Go
Raw Permalink Normal View History

2020-07-15 01:40:56 +08:00
package service
import (
"ferry/pkg/task"
"fmt"
"strings"
"github.com/spf13/viper"
)
/*
@Author : lanyulei
*/
func ExecTask(taskList []string, params string) {
2020-07-15 01:40:56 +08:00
for _, taskName := range taskList {
filePath := fmt.Sprintf("%v/%v", viper.GetString("script.path"), taskName)
if strings.HasSuffix(filePath, ".py") {
task.Send("python", filePath, params)
2020-07-15 01:40:56 +08:00
} else if strings.HasSuffix(filePath, ".sh") {
task.Send("shell", filePath, params)
2020-07-15 01:40:56 +08:00
}
}
}