2025-01-15 05:17:30 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
2025-01-15 05:25:55 +00:00
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
2025-01-15 05:17:30 +00:00
|
|
|
|
2025-01-15 05:46:36 +00:00
|
|
|
"code.30cm.net/digimon/app-cloudep-comment-server/gen_result/pb/comment"
|
|
|
|
"code.30cm.net/digimon/app-cloudep-comment-server/internal/config"
|
|
|
|
commentServer "code.30cm.net/digimon/app-cloudep-comment-server/internal/server/comment"
|
|
|
|
"code.30cm.net/digimon/app-cloudep-comment-server/internal/svc"
|
2025-01-15 05:17:30 +00:00
|
|
|
|
|
|
|
"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/comment.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) {
|
|
|
|
comment.RegisterCommentServer(grpcServer, commentServer.NewCommentServer(ctx))
|
|
|
|
|
|
|
|
if c.Mode == service.DevMode || c.Mode == service.TestMode {
|
|
|
|
reflection.Register(grpcServer)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
defer s.Stop()
|
|
|
|
|
2025-01-15 05:25:55 +00:00
|
|
|
logx.Infof("Starting rpc server at %s...\n", c.ListenOn)
|
2025-01-15 05:17:30 +00:00
|
|
|
s.Start()
|
|
|
|
}
|