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.

50 lines
1.4 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package main
import (
"flag"
"fmt"
"git.noahlan.cn/noahlan/ntool-biz/core/i18n"
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/internal/config"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/internal/server"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/internal/svc"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
"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", "rpc/core/etc/core.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c, conf.UseEnv())
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
core.RegisterCoreServer(grpcServer, server.NewCoreServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
// 添加服务端拦截器包括nstatus与i18n处理功能
s.AddUnaryInterceptors(nstatus.UnaryServerInterceptor(), i18n.UnaryServerInterceptor())
// 设置grpc 消息容量 50mb
s.AddOptions(
grpc.MaxRecvMsgSize(1024*1024*50),
grpc.MaxSendMsgSize(1024*1024*50),
)
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}