-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (38 loc) · 1019 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
package main
import (
"log"
"net"
"os"
"os/signal"
"syscall"
v1 "github.com/dbProjectRED/redimo/v1"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpczap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap"
grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
func main() {
lis, err := net.Listen("tcp", ":4772")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
logger, _ := zap.NewProduction()
server := grpc.NewServer(
grpc.UnaryInterceptor(
grpc_middleware.ChainUnaryServer(
grpczap.UnaryServerInterceptor(logger),
grpc_recovery.UnaryServerInterceptor(),
)))
v1.RegisterRedimoServiceServer(server, RedimoService{})
reflection.Register(server)
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
server.GracefulStop()
}()
log.Fatal(server.Serve(lis))
}
type RedimoService struct{}