app-cloudep-member-server/service.go

41 lines
1008 B
Go
Raw Normal View History

package main
import (
"flag"
"github.com/zeromicro/go-zero/core/logx"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/config"
accountServer "app-cloudep-member-server/internal/server/account"
"app-cloudep-member-server/internal/svc"
"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/service.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
member.RegisterAccountServer(grpcServer, accountServer.NewAccountServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
logx.Info("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}