MCPcopy Create free account
hub / github.com/cloudfoundry/bosh-agent / Run

Method Run

agent/script/parallel_script.go:37–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35func (s ParallelScript) Exists() bool { return true }
36
37func (s ParallelScript) Run() error {
38 existingScripts := s.findExistingScripts(s.allScripts)
39
40 s.logger.Info(s.logTag, "Will run %d %s scripts in parallel", len(existingScripts), s.name)
41
42 resultsChan := make(chan scriptResult)
43
44 for _, script := range existingScripts {
45 script := script
46 go func() { resultsChan <- scriptResult{script, script.Run()} }()
47 }
48
49 var failedScripts, passedScripts []string
50
51 for i := 0; i < len(existingScripts); i++ {
52 r := <-resultsChan
53 jobName := r.Script.Tag()
54
55 if r.Error == nil {
56 passedScripts = append(passedScripts, jobName)
57 s.logger.Info(s.logTag, "'%s' script has successfully executed", r.Script.Path())
58 } else {
59 failedScripts = append(failedScripts, jobName)
60 s.logger.Error(s.logTag, "'%s' script has failed with error: %s", r.Script.Path(), r.Error)
61 }
62 }
63
64 return s.summarizeErrs(passedScripts, failedScripts)
65}
66
67func (s ParallelScript) Cancel() error {
68 s.logger.Debug(s.logTag, "Canceling a parallel script")

Callers 2

RunMethod · 0.95
RunMethod · 0.95

Calls 7

findExistingScriptsMethod · 0.95
summarizeErrsMethod · 0.95
InfoMethod · 0.80
RunMethod · 0.65
TagMethod · 0.65
PathMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected