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.
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
3 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"flag"
|
||
|
"fmt"
|
||
|
"live-service/app/gift/rpc/msg_transfer"
|
||
|
|
||
|
"live-service/app/gift/rpc/internal/config"
|
||
|
"live-service/app/gift/rpc/internal/server"
|
||
|
"live-service/app/gift/rpc/internal/svc"
|
||
|
"live-service/app/gift/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/gift.yaml", "the config file")
|
||
|
|
||
|
func main() {
|
||
|
flag.Parse()
|
||
|
|
||
|
var c config.Config
|
||
|
conf.MustLoad(*configFile, &c)
|
||
|
ctx := svc.NewServiceContext(c)
|
||
|
svr := server.NewGiftServer(ctx)
|
||
|
|
||
|
msg_transfer.Init(context.Background(), ctx, svr)
|
||
|
msg_transfer.Run()
|
||
|
|
||
|
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
|
||
|
pb.RegisterGiftServer(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()
|
||
|
}
|