Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RunCmd = &cobra.Command{ Use: "wallet", Short: "", Long: ``, Run: func(cmd *cobra.Command, args []string) { defer log.Flush() defer func() { if r := recover(); r != nil { err, ok := r.(error) if !ok { err = fmt.Errorf("unknown error: %v", r) } log.Err(err).Panic("unknown error") } }() config.EnvPrefix = "STARTER" cfg := config.New("app.yml") err := initialize(cfg) if err != nil { log.Fatalf("main: initialize failed: %v", err) return } tp, err := cfg.TracerProvider("wallet") ctx, cancel := context.WithCancel(context.Background()) defer cancel() defer func(ctx context.Context) { ctx, cancel = context.WithTimeout(ctx, time.Second*5) defer cancel() if err := tp.Shutdown(ctx); err != nil { log.Err(err).Panic("tp shutdown failed") } }(ctx) lis, err := net.Listen("tcp", cfg.Wallet.GRPCBind) if err != nil { log.Fatalf("main: failed to grpc listen: %v", err) } grpcServer := grpc.NewServer( grpc.KeepaliveParams( keepalive.ServerParameters{ Time: (time.Duration(5) * time.Second), Timeout: (time.Duration(5) * time.Second), }, ), grpc.KeepaliveEnforcementPolicy( keepalive.EnforcementPolicy{ MinTime: (time.Duration(2) * time.Second), PermitWithoutStream: true, }, ), grpc.ChainUnaryInterceptor( otelgrpc.UnaryServerInterceptor(), walletGRPC.Interceptor(), ), grpc.StreamInterceptor(otelgrpc.StreamServerInterceptor()), ) walletProto.RegisterWalletServiceServer(grpcServer, _walletServer) log.Infof("wallet grpc service listen on %s", cfg.Wallet.GRPCBind) go func() { if err = grpcServer.Serve(lis); err != nil { log.Fatalf("main: failed to start agent order grpc server: %v", err) } }() stopChan := make(chan os.Signal, 1) signal.Notify(stopChan, syscall.SIGINT, syscall.SIGKILL, syscall.SIGHUP, syscall.SIGTERM) <-stopChan log.Info("main: shutting down server...") grpcServer.GracefulStop() log.Info("main: wallet grpc server gracefully stopped") }, }
RunCmd 是 wallet service 的進入口
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.