NetworkDiagnosticServer.go 616 B

1234567891011121314151617181920212223242526272829
  1. package main
  2. import (
  3. "cfTest/networkdiagnostic"
  4. pb "cfTest/networkdiagnostic/pb"
  5. "google.golang.org/grpc"
  6. "net"
  7. )
  8. const (
  9. networkDiagnosticPort = ":50050"
  10. )
  11. func main() {
  12. networkdiagnostic.Init()
  13. logger := networkdiagnostic.GetLogger()
  14. lis, err := net.Listen("tcp", networkDiagnosticPort)
  15. if err != nil {
  16. logger.Error("failed to listen: ", err)
  17. }
  18. s := grpc.NewServer()
  19. pb.RegisterNetworkDiagnosticServiceServer(s, &networkdiagnostic.NetworkDiagnosticServer{})
  20. logger.Println("server listening at ", lis.Addr())
  21. if err := s.Serve(lis); err != nil {
  22. logger.Error("failed to serve: ", err)
  23. }
  24. }