-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
39 lines (34 loc) · 973 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 (
"log"
"net"
"github.com/breez/data-sync/config"
"github.com/breez/data-sync/proto"
"google.golang.org/grpc"
)
func main() {
config, err := config.NewConfig()
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
grpcListener, err := net.Listen("tcp", config.GrpcListenAddress)
if err != nil {
log.Fatalf("Failed to listen: %v", err)
}
quitChan := make(chan struct{})
syncServer, err := NewPersistentSyncerServer(config)
if err != nil {
log.Fatalf("failed to create sync server: %v", err)
}
syncServer.Start(quitChan)
s := CreateServer(config, grpcListener, syncServer)
log.Printf("Server listening at %s", config.GrpcListenAddress)
if err := s.Serve(grpcListener); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}
func CreateServer(config *config.Config, listener net.Listener, syncServer proto.SyncerServer) *grpc.Server {
s := grpc.NewServer()
proto.RegisterSyncerServer(s, syncServer)
return s
}