-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
31 lines (29 loc) · 789 Bytes
/
main.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
package main
import (
config "github.com/astaxie/beego/config"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"log"
"net"
"scloud-grpc/controllers"
pb_hw "scloud-grpc/grpc/helloworld"
pb_ui "scloud-grpc/grpc/userinfo"
)
func main() {
iniconf, err := config.NewConfig("ini", "conf/app.conf")
if err != nil {
log.Fatalf("failed to iniconf: %v", err)
}
lis, err := net.Listen("tcp", iniconf.String("httpport"))
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
pb_hw.RegisterGreeterServer(s, &controllers.Server{})
pb_ui.RegisterGreeterServer(s, &controllers.Server{})
// Register reflection service on gRPC server.
reflection.Register(s)
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}