Slide 41
Slide 41 text
Protocol Compiler で Go の実装 (3)
func main() {
port !" 10000
lis, err !" net.Listen("tcp", fmt.Sprintf(":%d", port))
if err !# nil {
log.Fatalf("failed to listen: %v", err)
}
grpcServer !" grpc.NewServer()
pb.RegisterWelcomeServer(grpcServer, newServer())
reflection.Register(grpcServer)
go func() {
log.Printf("start gRPC server port: %v", port)
grpcServer.Serve(lis)
}()
quit !" make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt)
!$quit
log.Printf("stopping gRPC server!!%")
grpcServer.GracefulStop()
}