func monitorServices() { for { skylib.LoadConfig() for _, v := range skylib.NS.Services { if (v.Port != *skylib.Port) || (v.IPAddress != *skylib.BindIP) { portString := fmt.Sprintf("%s:%d", v.IPAddress, v.Port) x, err := rpc.DialHTTP("tcp", portString) if err != nil { log.Println("BAD CON:", err) v.RemoveFromConfig() skylib.Errors.Add(1) break } hc := skylib.HeartbeatRequest{Timestamp: time.Seconds()} hcr := skylib.HeartbeatResponse{} err = x.Call("Service.Ping", hc, &hcr) if err != nil { log.Println(err.String()) skylib.Errors.Add(1) } x.Close() skylib.Requests.Add(1) } } syscall.Sleep(2000 * 1000000) // sleep then do it again! } }
func monitorServices() { for { skylib.LoadConfig() for _, v := range skylib.NS.Services { fmt.Println(v) // Insert your code to do something for // each service here // or get rid of this loop // and do something else interesting! } syscall.Sleep(2000 * 1000000) // sleep then do it again! } }
func monitorServices() { println("Fear the reaper...") for { skylib.LoadConfig() clients := skylib.GetAllClientsByService("CommonService") println("#Agents:", len(clients)) for _, x := range clients { fmt.Printf("%v\n", x) // Insert your code to do something for // each service here // or get rid of this loop // and do something else interesting! x.Close() skylib.Requests.Add(1) // Should we count Heartbeat requests? } syscall.Sleep(2000 * 1000000) // sleep then do it again! } }
func monitorServices() { println("Fear the reaper...") for { skylib.LoadConfig() clients := skylib.GetAllClientsByService("CommonService") println("#Agents:", len(clients)) for _, x := range clients { hc := skylib.HeartbeatRequest{Timestamp: time.Seconds()} hcr := skylib.HeartbeatResponse{} err := x.Call("CommonService.Ping", hc, &hcr) if err != nil { panic(err) } fmt.Printf("hcr:%v\n", hcr) x.Close() skylib.Requests.Add(1) // Should be count Heartbeat requests? } syscall.Sleep(2000 * 1000000) // sleep then do it again! } }