Пример #1
0
// if this should not run, return false
func (tr *TaskRunner) Run(fc *flame.FlowContext) {

	taskGroups := scheduler.GroupTasks(fc)

	tr.Tasks = taskGroups[tr.option.TaskGroupId].Tasks

	if len(tr.Tasks) == 0 {
		log.Println("How can the task group has no tasks!")
		return
	}

	// 4. setup task input and output channels
	var wg sync.WaitGroup
	tr.connectInputsAndOutputs(&wg)
	// 6. starts to run the task locally
	for _, task := range tr.Tasks {
		wg.Add(1)
		go func(task *flame.Task) {
			defer wg.Done()
			task.Run()
		}(task)
	}
	// 7. need to close connected output channels
	wg.Wait()
}
Пример #2
0
// driver runs on local, controlling all tasks
func (fcd *FlowContextDriver) Run(fc *flame.FlowContext) {

	taskGroups := scheduler.GroupTasks(fc)

	// schedule to run the steps
	var wg sync.WaitGroup
	for _, tg := range taskGroups {
		wg.Add(1)
		go func(taskGroupId int) {
			defer wg.Done()
			dir, _ := os.Getwd()
			request := NewStartRequest(os.Args[0], dir,
				"-task.context.id",
				strconv.Itoa(fc.Id),
				"-task.taskGroup.id",
				strconv.Itoa(taskGroupId),
			)
			if err := RemoteExecute(fcd.option.Leader, "a1", request); err != nil {
				println("exeuction error:", err.Error())
			}
		}(tg.Id)
	}
	wg.Wait()
}