-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
49 lines (40 loc) · 1003 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
40
41
42
43
44
45
46
47
48
49
package main
import (
"flag"
"fmt"
pb "github.com/aau-network-security/haaukins-store/proto"
rpc "github.com/aau-network-security/haaukins-store/util"
_ "github.com/lib/pq"
"log"
"net"
)
const (
defaultConfigFile = "config.yml"
port = ":50051"
)
func main() {
confFilePtr := flag.String("config", defaultConfigFile, "configuration file")
flag.Parse()
c, err := rpc.NewConfigFromFile(*confFilePtr)
if err != nil {
log.Fatalf("unable to read configuration file \"%s\": %s\n", *confFilePtr, err)
}
s, err := rpc.InitilizegRPCServer(c)
if err != nil {
return
}
lis, err := net.Listen("tcp", port)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
opts, err := s.GrpcOpts(c)
if err != nil {
log.Fatalf("failed to retrieve server options %s", err.Error())
}
gRPCServer := s.GetGRPCServer(opts...)
pb.RegisterStoreServer(gRPCServer, s)
fmt.Println("waiting client")
if err := gRPCServer.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}