mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
engine: 'rengine' is a small command-line utility to debug remote engine
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
parent
b63b98ee27
commit
7e3624a498
1 changed files with 43 additions and 0 deletions
43
engine/rengine/main.go
Normal file
43
engine/rengine/main.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/engine"
|
||||
"github.com/dotcloud/docker/pkg/beam"
|
||||
"net"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
eng := engine.New()
|
||||
|
||||
c, err := net.Dial("unix", "beam.sock")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
return
|
||||
}
|
||||
defer c.Close()
|
||||
f, err := c.(*net.UnixConn).File()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
child, err := beam.FileConn(f)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
return
|
||||
}
|
||||
defer child.Close()
|
||||
|
||||
sender := engine.NewSender(child)
|
||||
sender.Install(eng)
|
||||
|
||||
cmd := eng.Job(os.Args[1], os.Args[2:]...)
|
||||
cmd.Stdout.Add(os.Stdout)
|
||||
cmd.Stderr.Add(os.Stderr)
|
||||
if err := cmd.Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue