42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"flag"
|
||
|
"fmt"
|
||
|
|
||
|
"app-cloudep-feed-service/gen_result/pb/feed"
|
||
|
"app-cloudep-feed-service/internal/config"
|
||
|
commentserviceServer "app-cloudep-feed-service/internal/server/commentservice"
|
||
|
postserviceServer "app-cloudep-feed-service/internal/server/postservice"
|
||
|
"app-cloudep-feed-service/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"
|
||
|
)
|
||
|
|
||
|
var configFile = flag.String("f", "etc/feed.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) {
|
||
|
feed.RegisterPostServiceServer(grpcServer, postserviceServer.NewPostServiceServer(ctx))
|
||
|
feed.RegisterCommentServiceServer(grpcServer, commentserviceServer.NewCommentServiceServer(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()
|
||
|
}
|