func main() { rpcAddr := flag.String("rpcaddr", ":1115", "rpc listen address") httpAddr := flag.String("httpaddr", ":8080", "http frontend listen address") flag.Parse() var s Server f, err := NewHTTPFrontend(*httpAddr) if err != nil { log.Fatal(err) } s.HTTPFrontend = f rpcplus.Register(&Router{s}) rpcplus.HandleHTTP() go http.ListenAndServe(*rpcAddr, nil) d, err := discover.NewClient() if err != nil { log.Fatal(err) } if hostPort := strings.SplitN(*rpcAddr, ":", 2); hostPort[0] != "" { err = d.RegisterWithHost("flynn-strowger-rpc", hostPort[0], hostPort[1], nil) } else { err = d.Register("flynn-strowger-rpc", hostPort[1], nil) } if err != nil { log.Fatal(err) } s.ListenAndServe(nil) }
func ListenAndServe(server *Agent) error { rpcplus.HandleHTTP() err := rpcplus.Register(server) if err != nil { return err } return http.ListenAndServe(server.Address, nil) }
func main() { flag.Parse() rpcplus.HandleHTTP() l, err := net.Listen("tcp", *listenAddr) if err != nil { log.Fatal(err) } d, err := discover.NewClient() if err != nil { log.Fatal(err) } if hostPort := strings.SplitN(*listenAddr, ":", 2); hostPort[0] != "" { err = d.RegisterWithHost("flynn-sampi", hostPort[0], hostPort[1], nil) } else { err = d.Register("flynn-sampi", hostPort[1], nil) } if err != nil { log.Fatal(err) } http.Serve(l, nil) }
func rpcServer() { rpcplus.Register(&Host{}) rpcplus.HandleHTTP() http.ListenAndServe(":1113", nil) }