Merge branch 'master' into collect_ip

pull/37/head
Minh Doan 6 years ago
commit 38647899e3
  1. 10
      aws-experiment-launch/experiment/commander/main.go
  2. 8
      aws-experiment-launch/experiment/soldier/main.go

@ -19,12 +19,10 @@ var (
func SocketClient(addr string) {
conn, err := net.Dial("tcp", addr)
defer conn.Close()
if err != nil {
log.Fatalln(err)
}
defer conn.Close()
message := "init http://localhost:8080/" + *configFile
conn.Write([]byte(message))
@ -44,7 +42,11 @@ func main() {
for _, config := range configs {
ip := config[0]
port := config[1]
port := "1" + config[1] // the port number of solider is "1" + node port
duty := config[2]
if duty == "client" {
continue
}
addr := strings.Join([]string{ip, port}, ":")
SocketClient(addr)
}

@ -25,13 +25,14 @@ var (
)
func socketServer() {
listen, err := net.Listen("tcp4", ":"+*port)
soldierPort := "1" + *port // the soldier port is "1" + node port
listen, err := net.Listen("tcp4", ":"+soldierPort)
if err != nil {
log.Fatalf("Socket listen port %s failed,%s", *port, err)
log.Fatalf("Socket listen port %s failed,%s", soldierPort, err)
os.Exit(1)
}
defer listen.Close()
log.Printf("Begin listen for command on port: %s", *port)
log.Printf("Begin listen for command on port: %s", soldierPort)
for {
conn, err := listen.Accept()
@ -132,6 +133,7 @@ func handleInitCommand(args []string, w *bufio.Writer) {
run()
log.Println("Successfully init-ed")
w.Write([]byte("Successfully init-ed"))
w.Flush()
}

Loading…
Cancel
Save