package main import ( "flag" "fmt" "perms-system-server/internal/config" "perms-system-server/internal/handler" "perms-system-server/internal/response" "perms-system-server/internal/server" "perms-system-server/internal/svc" "perms-system-server/pb" "github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/rest" "github.com/zeromicro/go-zero/zrpc" "google.golang.org/grpc" "google.golang.org/grpc/reflection" ) var configFile = flag.String("f", "etc/perm-api.yaml", "the config file") func main() { flag.Parse() var c config.Config conf.MustLoad(*configFile, &c) response.Setup() svcCtx := svc.NewServiceContext(c) go func() { rpcServer := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { pb.RegisterPermServiceServer(grpcServer, server.NewPermServer(svcCtx)) reflection.Register(grpcServer) }) defer rpcServer.Stop() fmt.Printf("Starting gRPC server at %s...\n", c.RpcServerConf.ListenOn) rpcServer.Start() }() httpServer := rest.MustNewServer(c.RestConf) defer httpServer.Stop() handler.RegisterHandlers(httpServer, svcCtx) fmt.Printf("Starting HTTP server at %s:%d...\n", c.Host, c.Port) httpServer.Start() }