MCPcopy
hub / github.com/grpc/grpc-go / main

Function main

examples/route_guide/server/server.go:218–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

216}
217
218func main() {
219 flag.Parse()
220 lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", *port))
221 if err != nil {
222 log.Fatalf("failed to listen: %v", err)
223 }
224 var opts []grpc.ServerOption
225 if *tls {
226 if *certFile == "" {
227 *certFile = data.Path("x509/server_cert.pem")
228 }
229 if *keyFile == "" {
230 *keyFile = data.Path("x509/server_key.pem")
231 }
232 creds, err := credentials.NewServerTLSFromFile(*certFile, *keyFile)
233 if err != nil {
234 log.Fatalf("Failed to generate credentials: %v", err)
235 }
236 opts = []grpc.ServerOption{grpc.Creds(creds)}
237 }
238 grpcServer := grpc.NewServer(opts...)
239 pb.RegisterRouteGuideServer(grpcServer, newServer())
240 grpcServer.Serve(lis)
241}
242
243// exampleData is a copy of testdata/route_guide_db.json. It's to avoid
244// specifying file path with `go run`.

Callers

nothing calls this directly

Calls 8

ServeMethod · 0.95
PathFunction · 0.92
NewServerTLSFromFileFunction · 0.92
CredsFunction · 0.92
NewServerFunction · 0.92
newServerFunction · 0.85
ParseMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected