app-cloudep-permission-server/permission.go

40 lines
1.0 KiB
Go
Raw Permalink Normal View History

package main
import (
"flag"
"fmt"
"app-cloudep-permission-server/gen_result/pb/permission"
"app-cloudep-permission-server/internal/config"
tokenserviceServer "app-cloudep-permission-server/internal/server/tokenservice"
"app-cloudep-permission-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"
)
2024-08-26 08:33:48 +00:00
var configFile = flag.String("f", "etc/permission.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) {
permission.RegisterTokenServiceServer(grpcServer, tokenserviceServer.NewTokenServiceServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}