-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (40 loc) · 1.02 KB
/
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
50
51
package main
import (
"context"
"net"
"os"
"os/signal"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"github.com/SaucySalamander/owl-db/cmd"
"github.com/SaucySalamander/owl-db/internal/config"
internal_grpc "github.com/SaucySalamander/owl-db/pkg/gRPC"
"google.golang.org/grpc"
_ "github.com/lib/pq"
)
func main() {
cmd.Execute()
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
shutdown, err := config.InitProvider()
if err != nil {
log.Fatal().Err(err).Send()
}
defer func() {
if err := shutdown(ctx); err != nil {
log.Fatal().Err(err).Msg("failed to shutdown TracerProvider")
}
}()
var host = viper.GetString("server.host")
var port = viper.GetString("server.port")
lis, err := net.Listen("tcp", host+":"+port)
if err != nil {
log.Fatal().Err(err).Send()
}
server := grpc.NewServer()
internal_grpc.RegisterServer(server)
log.Info().Msgf("Started server on port: %s", port)
if err := server.Serve(lis); err != nil {
log.Fatal().Err(err).Send()
}
}