You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB
Go

package main
import (
"flag"
"fmt"
"github.com/zeromicro/go-zero/core/conf"
"live-service/app/user_center/rpc/internal/config"
"live-service/app/user_center/rpc/internal/logic/gift_collect"
"live-service/app/user_center/rpc/internal/logic/platform_user"
"live-service/app/user_center/rpc/internal/logic/statistics"
"live-service/app/user_center/rpc/internal/server"
"live-service/app/user_center/rpc/internal/svc"
"live-service/app/user_center/rpc/pb"
"live-service/common/interceptor/rpcserver"
"os"
"path/filepath"
"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/user_center.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
var cg config.GameConfig
config.MustLoad(*configFile, &cg)
err := os.Setenv("ZONEINFO", filepath.Join("./", "zoneinfo.zip"))
if err != nil {
panic(err)
}
ctx := svc.NewServiceContext(&c, &cg)
svr := server.NewUserCenterServer(ctx)
platform_user.InitUserRetriever(ctx)
statistics.InitRankJob(ctx)
gift_collect.InitCollector(ctx)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
pb.RegisterUserCenterServer(grpcServer, svr)
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
s.AddUnaryInterceptors(rpcserver.LoggerInterceptor)
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}