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) { func SocketClient(addr string) {
conn, err := net.Dial("tcp", addr) conn, err := net.Dial("tcp", addr)
defer conn.Close()
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
defer conn.Close()
message := "init http://localhost:8080/" + *configFile message := "init http://localhost:8080/" + *configFile
conn.Write([]byte(message)) conn.Write([]byte(message))
@ -44,7 +42,11 @@ func main() {
for _, config := range configs { for _, config := range configs {
ip := config[0] 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}, ":") addr := strings.Join([]string{ip, port}, ":")
SocketClient(addr) SocketClient(addr)
} }

@ -25,13 +25,14 @@ var (
) )
func socketServer() { 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 { 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) os.Exit(1)
} }
defer listen.Close() defer listen.Close()
log.Printf("Begin listen for command on port: %s", *port) log.Printf("Begin listen for command on port: %s", soldierPort)
for { for {
conn, err := listen.Accept() conn, err := listen.Accept()
@ -132,6 +133,7 @@ func handleInitCommand(args []string, w *bufio.Writer) {
run() run()
log.Println("Successfully init-ed")
w.Write([]byte("Successfully init-ed")) w.Write([]byte("Successfully init-ed"))
w.Flush() w.Flush()
} }

Loading…
Cancel
Save