-
Notifications
You must be signed in to change notification settings - Fork 1
/
user.go
43 lines (38 loc) · 883 Bytes
/
user.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
40
41
42
43
package main
import (
"net"
"github.com/cestlascorpion/offlinepush/core"
"github.com/cestlascorpion/offlinepush/proto"
"github.com/cestlascorpion/offlinepush/user"
"github.com/jinzhu/configor"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
func main() {
lis, err := net.Listen("tcp", core.UserServerAddr)
if err != nil {
log.Fatalf("listen failed err %+v", err)
return
}
conf := &core.PushConfig{}
err = configor.Load(conf, "conf.json")
if err != nil {
log.Fatalf("config failed err %+v", err)
return
}
svr, err := user.NewServer(conf)
if err != nil {
log.Fatalf("new server failed err %+v", err)
return
}
defer svr.Close()
s := grpc.NewServer()
proto.RegisterUserServer(s, svr)
reflection.Register(s)
err = s.Serve(lis)
if err != nil {
log.Fatalf("serve failed err %+v", err)
return
}
}