app-cloudep-notification-se.../notification.go

39 lines
1.0 KiB
Go
Raw Permalink Normal View History

2024-08-20 06:35:14 +00:00
package main
import (
"app-cloudep-notification-service/gen_result/pb/notification"
"app-cloudep-notification-service/internal/config"
senderserviceServer "app-cloudep-notification-service/internal/server/senderservice"
"app-cloudep-notification-service/internal/svc"
2024-09-04 19:09:48 +00:00
"flag"
"log"
2024-08-20 06:35:14 +00:00
"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"
)
2024-08-26 08:34:16 +00:00
var configFile = flag.String("f", "etc/notification.yaml", "the config file")
2024-08-20 06:35:14 +00:00
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) {
notification.RegisterSenderServiceServer(grpcServer, senderserviceServer.NewSenderServiceServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
2024-09-04 19:09:48 +00:00
log.Printf("Starting rpc server at %s...\n", c.ListenOn)
2024-08-20 06:35:14 +00:00
s.Start()
}