12345678910111213141516171819202122232425262728293031323334353637383940 |
- package main
- import (
- "flag"
- "fmt"
- "ylink/core/transfer/rpc/internal/config"
- "ylink/core/transfer/rpc/internal/server"
- "ylink/core/transfer/rpc/internal/svc"
- "ylink/core/transfer/rpc/pb"
- "github.com/zeromicro/go-zero/core/conf"
- "github.com/zeromicro/go-zero/core/service"
- "github.com/zeromicro/go-zero/zrpc"
- "google.golang.org/grpc"
- "google.golang.org/grpc/reflection"
- )
- var configFile = flag.String("f", "etc/transfer.yaml", "the config file")
- func main() {
- flag.Parse()
- var c config.Config
- conf.MustLoad(*configFile, &c)
- ctx := svc.NewServiceContext(c)
- svr := server.NewTransferServer(ctx)
- s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
- pb.RegisterTransferServer(grpcServer, svr)
- if c.Mode == service.DevMode || c.Mode == service.TestMode {
- reflection.Register(grpcServer)
- }
- })
- defer s.Stop()
- fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
- s.Start()
- }
|