mirror of https://github.com/docker/docs.git
beam/examples/beamsh: support for background commands with '&' terminator
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
parent
60a0531497
commit
e34273628f
|
@ -136,11 +136,21 @@ func scriptString(script []*dockerscript.Command) string {
|
||||||
func executeScript(client *net.UnixConn, script []*dockerscript.Command) error {
|
func executeScript(client *net.UnixConn, script []*dockerscript.Command) error {
|
||||||
Debugf("executeScript(%s)\n", scriptString(script))
|
Debugf("executeScript(%s)\n", scriptString(script))
|
||||||
defer Debugf("executeScript(%s) DONE\n", scriptString(script))
|
defer Debugf("executeScript(%s) DONE\n", scriptString(script))
|
||||||
|
var background sync.WaitGroup
|
||||||
|
defer background.Wait()
|
||||||
for _, cmd := range script {
|
for _, cmd := range script {
|
||||||
|
if cmd.Background {
|
||||||
|
background.Add(1)
|
||||||
|
go func(client *net.UnixConn, cmd *dockerscript.Command) {
|
||||||
|
executeCommand(client, cmd)
|
||||||
|
background.Done()
|
||||||
|
}(client, cmd)
|
||||||
|
} else {
|
||||||
if err := executeCommand(client, cmd); err != nil {
|
if err := executeCommand(client, cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue