grpc.go 525 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. Copyright © 2022 NAME HERE <EMAIL ADDRESS>
  3. */
  4. package cmd
  5. import (
  6. "kpt-grpc-demo/config"
  7. "kpt-grpc-demo/dep"
  8. "kpt-grpc-demo/util/svcutil"
  9. "github.com/spf13/cobra"
  10. )
  11. // grpcCmd represents the grpc command
  12. var grpcCmd = &cobra.Command{
  13. Use: "grpc",
  14. Short: "start grpc server",
  15. Run: func(cmd *cobra.Command, args []string) {
  16. svcutil.StandBy(config.Options().HTTPServerAddr, func() {
  17. server := dep.DIGRPCServer()
  18. defer func() {
  19. _ = server.Close()
  20. }()
  21. server.Run()
  22. })
  23. },
  24. }
  25. func init() {
  26. }