-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (32 loc) · 773 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
32
33
34
35
36
37
38
39
package main
import (
"fmt"
"log"
"net"
"os"
"github.com/azar-intelops/grpc-code-gen/server/controllers"
"github.com/azar-intelops/grpc-code-gen/server/pb"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
var (
host = "localhost"
port = "50051"
)
func main() {
addr := fmt.Sprintf("%s:%s", host, port)
lis, err := net.Listen("tcp", addr)
if err != nil {
log.Println("error starting tcp listener: ", err)
os.Exit(1)
}
log.Println("tcp listener started at port: ", port)
grpcServer := grpc.NewServer()
ctServer := controllers.NewServer()
pb.RegisterBasicServiceServer(grpcServer, ctServer)
reflection.Register(grpcServer)
if err := grpcServer.Serve(lis); err != nil {
log.Println("error serving grpc: ", err)
os.Exit(1)
}
}