Ejemplo n.º 1
0
func (server *Server) ListenAndServe() {
	port := server.Config.GetPortString()

	//Listen
	lis, err := net.Listen("tcp", port)

	if err != nil {
		log.Fatalf("server.go: failed to listen: %v", err)
	}

	grpcServer := grpc.NewServer()
	pb.RegisterNotificationServiceServer(grpcServer, server)

	log.Infoln("server.go: Listening", port)
	//Serve
	grpcServer.Serve(lis)
}
Ejemplo n.º 2
0
func (server *Server) ListenAndServe() error {
	port := server.Config.GetPortString()

	//Listen
	lis, err := net.Listen("tcp", port)
	if err != nil {
		return err
	}

	grpcServer := grpc.NewServer()
	pb.RegisterNotificationServiceServer(grpcServer, server)
	hs := health.New(server)
	grpc_health_v1.RegisterHealthServer(grpcServer, hs)
	go http.ListenAndServe(server.Config.GetHealthPortString(), hs)
	log.Infoln("server.go: Listening", port)
	//Serve
	return grpcServer.Serve(lis)
}