Files
ocean/gallery/gallery.go
konjacpotato 9fa26bc026
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 15m24s
use logx
2025-06-06 23:12:49 +08:00

40 lines
921 B
Go

package main
import (
"flag"
"godemo/gallery/gallery"
"godemo/gallery/internal/config"
"godemo/gallery/internal/server"
"godemo/gallery/internal/svc"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx"
"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/gallery.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) {
gallery.RegisterGalleryServer(grpcServer, server.NewGalleryServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
logx.Infof("Starting rpc server at %s...", c.ListenOn)
s.Start()
}