1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package main
- import (
- "flag"
- "fmt"
- "bp.jydev.jianyu360.cn/BaseService/fileCenter/rpc/internal/config"
- "bp.jydev.jianyu360.cn/BaseService/fileCenter/rpc/internal/server"
- "bp.jydev.jianyu360.cn/BaseService/fileCenter/rpc/internal/svc"
- "bp.jydev.jianyu360.cn/BaseService/fileCenter/rpc/pb"
- "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/filecenter.yaml", "the config file")
- func main() {
- flag.Parse()
- var c config.Config
- conf.MustLoad(*configFile, &config.C)
- c = config.C
- ctx := svc.NewServiceContext(c)
- svr := server.NewFileCenterServer(ctx)
- s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
- pb.RegisterFileCenterServer(grpcServer, svr)
- 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()
- }
|