mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
beam/examples/beamsh: first try at nested execution
The "wiring" is broken because engine does not keep a reference for handling introspection calls. Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
parent
8697490740
commit
6072dec9e7
1 changed files with 33 additions and 0 deletions
|
@ -66,6 +66,9 @@ func executeScript(client *net.UnixConn, script []*dockerscript.Command) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatal(err)
|
Fatal(err)
|
||||||
}
|
}
|
||||||
|
// Recursively execute child-commands as commands to the new job
|
||||||
|
// executeScript blocks until commands are done, so this is depth-first recursion.
|
||||||
|
executeScript(job, cmd.Children)
|
||||||
// TODO: pass a default handler to deal with 'status'
|
// TODO: pass a default handler to deal with 'status'
|
||||||
// --> use beam chaining?
|
// --> use beam chaining?
|
||||||
Debugf("Listening for reply messages\n")
|
Debugf("Listening for reply messages\n")
|
||||||
|
@ -151,6 +154,34 @@ func parseEnv(args []string) ([]string, map[string]string) {
|
||||||
return argsOut, env
|
return argsOut, env
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CmdTrace(args []string, f *os.File) {
|
||||||
|
resp, err := beam.FdConn(int(f.Fd()))
|
||||||
|
if err != nil {
|
||||||
|
Fatal(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Close()
|
||||||
|
for {
|
||||||
|
Logf("[trace] waiting for a message\n")
|
||||||
|
payload, attachment, err := beam.Receive(resp)
|
||||||
|
if err != nil {
|
||||||
|
Logf("[trace] error waiting for message\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Logf("[trace] received message!\n")
|
||||||
|
msg, err := data.Decode(string(payload))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("===> %s\n", payload)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("===> %v\n", msg)
|
||||||
|
}
|
||||||
|
if err := beam.Send(resp, payload, attachment); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func CmdLog(args []string, f *os.File) {
|
func CmdLog(args []string, f *os.File) {
|
||||||
defer Debugf("CmdLog done\n")
|
defer Debugf("CmdLog done\n")
|
||||||
var name string
|
var name string
|
||||||
|
@ -218,6 +249,8 @@ func builtinsHandler(args []string, attachment *os.File) {
|
||||||
CmdEcho(args, attachment)
|
CmdEcho(args, attachment)
|
||||||
} else if args[0] == "log" {
|
} else if args[0] == "log" {
|
||||||
CmdLog(args, attachment)
|
CmdLog(args, attachment)
|
||||||
|
} else if args[0] == "trace" {
|
||||||
|
CmdTrace(args, attachment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue