app-cloudep-reaction-service/reaction.go

41 lines
1.1 KiB
Go
Raw Normal View History

2025-01-15 11:33:04 +00:00
package main
import (
"flag"
"github.com/zeromicro/go-zero/core/logx"
"code.30cm.net/digimon/app-cloudep-reaction-service/gen_result/pb/reaction"
"code.30cm.net/digimon/app-cloudep-reaction-service/internal/config"
reactionServer "code.30cm.net/digimon/app-cloudep-reaction-service/internal/server/reaction"
"code.30cm.net/digimon/app-cloudep-reaction-service/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/reaction.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) {
reaction.RegisterReactionServer(grpcServer, reactionServer.NewReactionServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
logx.Infof("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}