first commit
This commit is contained in:
43
apps/user/user.go
Normal file
43
apps/user/user.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"tianyuan-api/apps/user/internal/config"
|
||||
authServer "tianyuan-api/apps/user/internal/server/auth"
|
||||
enterpriseServer "tianyuan-api/apps/user/internal/server/enterprise"
|
||||
userServer "tianyuan-api/apps/user/internal/server/user"
|
||||
"tianyuan-api/apps/user/internal/svc"
|
||||
"tianyuan-api/apps/user/user"
|
||||
|
||||
"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/user.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) {
|
||||
user.RegisterEnterpriseServer(grpcServer, enterpriseServer.NewEnterpriseServer(ctx))
|
||||
user.RegisterAuthServer(grpcServer, authServer.NewAuthServer(ctx))
|
||||
user.RegisterUserServer(grpcServer, userServer.NewUserServer(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()
|
||||
}
|
||||
Reference in New Issue
Block a user