package main import ( "bp.jydev.jianyu360.cn/BaseService/userCenter/entity" "flag" "fmt" _ "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/internal/config" _ "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/internal/db" "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/internal/server" "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/internal/svc" "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb" "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/timetask" "github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/service" "github.com/zeromicro/go-zero/zrpc" "google.golang.org/grpc" "google.golang.org/grpc/reflection" ) func main() { flag.Parse() ctx := svc.NewServiceContext(entity.ConfigJson) svr := server.NewUserCenterServer(ctx) // logx 根据配置初始化 logx.MustSetup(entity.ConfigJson.Logx) s := zrpc.MustNewServer(entity.ConfigJson.RpcServerConf, func(grpcServer *grpc.Server) { pb.RegisterUserCenterServer(grpcServer, svr) if entity.ConfigJson.Mode == service.DevMode || entity.ConfigJson.Mode == service.TestMode { reflection.Register(grpcServer) } }) defer s.Stop() go timetask.Run() fmt.Printf("Starting rpc server at %s...\n", entity.ConfigJson.ListenOn) s.Start() }