2024-10-06 07:02:30 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-10-23 09:50:11 +00:00
|
|
|
"app-cloudep-order-server/gen_result/pb/order"
|
2024-10-06 07:02:30 +00:00
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"app-cloudep-order-server/internal/config"
|
|
|
|
orderserviceServer "app-cloudep-order-server/internal/server/orderservice"
|
|
|
|
"app-cloudep-order-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"
|
|
|
|
)
|
|
|
|
|
|
|
|
var configFile = flag.String("f", "etc/order.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) {
|
2024-10-23 09:50:11 +00:00
|
|
|
order.RegisterOrderServiceServer(grpcServer, orderserviceServer.NewOrderServiceServer(ctx))
|
2024-10-06 07:02:30 +00:00
|
|
|
|
|
|
|
if c.Mode == service.DevMode || c.Mode == service.TestMode {
|
|
|
|
reflection.Register(grpcServer)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
defer s.Stop()
|
|
|
|
|
2024-10-23 09:50:11 +00:00
|
|
|
//nolint:forbidigo
|
2024-10-06 07:02:30 +00:00
|
|
|
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
|
|
|
|
s.Start()
|
|
|
|
}
|