functional-tester/etcd-agent: configurable agent port

To make local testing easier.
This commit is contained in:
Gyu-Ho Lee
2016-02-04 21:10:30 -08:00
parent f003e421f5
commit 8e1325d9e1
2 changed files with 8 additions and 5 deletions

View File

@@ -17,17 +17,20 @@ package main
import (
"flag"
"log"
"os"
"path/filepath"
)
func main() {
etcdPath := flag.String("etcd-path", "/opt/etcd/bin/etcd", "the path to etcd binary")
etcdPath := flag.String("etcd-path", filepath.Join(os.Getenv("GOPATH"), "bin/etcd"), "the path to etcd binary")
port := flag.String("port", ":9027", "port to serve agent server")
flag.Parse()
a, err := newAgent(*etcdPath)
if err != nil {
log.Fatal(err)
}
a.serveRPC()
a.serveRPC(*port)
var done chan struct{}
<-done

View File

@@ -23,14 +23,14 @@ import (
"github.com/coreos/etcd/tools/functional-tester/etcd-agent/client"
)
func (a *Agent) serveRPC() {
func (a *Agent) serveRPC(port string) {
rpc.Register(a)
rpc.HandleHTTP()
l, e := net.Listen("tcp", ":9027")
l, e := net.Listen("tcp", port)
if e != nil {
log.Fatal("agent:", e)
}
log.Println("agent listening on :9027")
log.Println("agent listening on", port)
go http.Serve(l, nil)
}