-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (34 loc) · 1.03 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
// Copyright (c) 2022 Isaque Veras
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package main
import (
"log"
"golang.org/x/sync/errgroup"
"github.com/isaqueveras/powersso/config"
"github.com/isaqueveras/powersso/database/postgres"
"github.com/isaqueveras/powersso/scripts"
"github.com/isaqueveras/powersso/server"
"github.com/isaqueveras/powersso/utils"
)
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
config.LoadConfig()
cfg := config.Get()
logg := utils.NewLogger(cfg)
logg.InitLogger()
postgres.OpenConnections(cfg)
defer postgres.CloseConnections()
scripts.Init(logg)
group := &errgroup.Group{}
server := server.NewServer(cfg, logg, group)
if err := server.ServerHTTP(); err != nil {
logg.Fatal("Error while serving the server HTTP: ", err)
}
if err := server.ServerGRPC(); err != nil {
logg.Fatal("Error while serving the server GRPC: ", err)
}
if err := group.Wait(); err != nil {
logg.Fatal("Error while serving the servers: ", err)
}
}