Fix variable binding bug when saving logs

This commit is contained in:
Filip Grzadkowski 2015-06-17 22:21:18 +02:00
parent 9a764b764b
commit ffb96e5a6d

View File

@ -76,7 +76,7 @@ func logCore(cmds []command, hosts []string, dir, provider string) {
fmt.Printf("SSH'ing to all nodes and running %s\n", cmd.cmd)
for _, host := range hosts {
wg.Add(1)
go func() {
go func(cmd command, host string) {
defer wg.Done()
logfile := fmt.Sprintf("%s/%s-%s.log", dir, host, cmd.component)
fmt.Printf("Writing to %s.\n", logfile)
@ -87,7 +87,7 @@ func logCore(cmds []command, hosts []string, dir, provider string) {
if err := ioutil.WriteFile(logfile, []byte(stdout+stderr), 0777); err != nil {
fmt.Printf("Error writing logfile: %v\n", err)
}
}()
}(cmd, host)
}
}
wg.Wait()