-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (34 loc) · 1.28 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
package main
import (
"fmt"
"log"
"strconv"
"github.com/vesicash/auth-ms/internal/config"
"github.com/vesicash/auth-ms/internal/models/migrations"
"github.com/vesicash/auth-ms/pkg/repository/storage/postgresql"
"github.com/vesicash/auth-ms/utility"
"github.com/go-playground/validator/v10"
"github.com/vesicash/auth-ms/pkg/router"
)
func main() {
logger := utility.NewLogger() //Warning !!!!! Do not recreate this action anywhere on the app
configuration := config.Setup(logger, "./app")
postgresql.ConnectToDatabases(logger, configuration.Databases)
validatorRef := validator.New()
db := postgresql.Connection()
shouldMigrate, _ := strconv.ParseBool(configuration.Databases.Migrate)
if shouldMigrate {
migrations.RunAllMigrations(db)
}
r := router.Setup(logger, validatorRef, db, &configuration.App)
rM := router.SetupMetrics(&configuration.App)
go func(logger *utility.Logger, metricsPort string) {
utility.LogAndPrint(logger, fmt.Sprintf("Metric Server is starting at 127.0.0.1:%s", metricsPort))
err := rM.Run(":" + metricsPort)
if err != nil {
log.Fatal(err)
}
}(logger, configuration.Server.MetricsPort)
utility.LogAndPrint(logger, fmt.Sprintf("Server is starting at 127.0.0.1:%s", configuration.Server.Port))
log.Fatal(r.Run(":" + configuration.Server.Port))
}