-
Notifications
You must be signed in to change notification settings - Fork 12
/
mcms.go
39 lines (30 loc) · 1 KB
/
mcms.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"flag"
"fmt"
"github.com/suyuan32/simple-admin-message-center/internal/config"
"github.com/suyuan32/simple-admin-message-center/internal/server"
"github.com/suyuan32/simple-admin-message-center/internal/svc"
"github.com/suyuan32/simple-admin-message-center/types/mcms"
"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/mcms.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c, conf.UseEnv())
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
mcms.RegisterMcmsServer(grpcServer, server.NewMcmsServer(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()
}