This commit is contained in:
Victor Vieux 2013-05-21 10:14:58 +00:00
Родитель e6e13d6ade
Коммит a3ccec197e
2 изменённых файлов: 8 добавлений и 6 удалений

Просмотреть файл

@ -30,8 +30,8 @@ var (
GIT_COMMIT string GIT_COMMIT string
) )
func ParseCommands(args ...string) error { func ParseCommands(host string, port int, args ...string) error {
cli := NewDockerCli("0.0.0.0", 4243) cli := NewDockerCli(host, port)
if len(args) > 0 { if len(args) > 0 {
methodName := "Cmd" + strings.ToUpper(args[0][:1]) + strings.ToLower(args[0][1:]) methodName := "Cmd" + strings.ToUpper(args[0][:1]) + strings.ToLower(args[0][1:])

Просмотреть файл

@ -29,6 +29,8 @@ func main() {
flAutoRestart := flag.Bool("r", false, "Restart previously running containers") flAutoRestart := flag.Bool("r", false, "Restart previously running containers")
bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge") bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge")
pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID") pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID")
port := flag.Int("port", 4243, "Port to listen/connect to")
host := flag.String("host", "0.0.0.0", "Host bind/connect to")
flag.Parse() flag.Parse()
if *bridgeName != "" { if *bridgeName != "" {
docker.NetworkBridgeIface = *bridgeName docker.NetworkBridgeIface = *bridgeName
@ -44,12 +46,12 @@ func main() {
flag.Usage() flag.Usage()
return return
} }
if err := daemon(*pidfile, *flAutoRestart); err != nil { if err := daemon(*pidfile, *host, *port, *flAutoRestart); err != nil {
log.Fatal(err) log.Fatal(err)
os.Exit(-1) os.Exit(-1)
} }
} else { } else {
if err := docker.ParseCommands(flag.Args()...); err != nil { if err := docker.ParseCommands(*host, *port, flag.Args()...); err != nil {
log.Fatal(err) log.Fatal(err)
os.Exit(-1) os.Exit(-1)
} }
@ -83,7 +85,7 @@ func removePidFile(pidfile string) {
} }
} }
func daemon(pidfile string, autoRestart bool) error { func daemon(pidfile, host string, port int, autoRestart bool) error {
if err := createPidFile(pidfile); err != nil { if err := createPidFile(pidfile); err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -103,5 +105,5 @@ func daemon(pidfile string, autoRestart bool) error {
return err return err
} }
return docker.ListenAndServe("0.0.0.0:4243", server, true) return docker.ListenAndServe(fmt.Sprintf("%s:%d", host, port), server, true)
} }