-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (32 loc) · 852 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
package main
import (
"saas/config"
"saas/infra/database"
"saas/infra/logger"
"saas/migrations"
"saas/routers"
"saas/seeds"
"time"
"github.com/spf13/viper"
)
func main() {
// set timezone
viper.SetDefault("SERVER_TIMEZONE", "America/Los_Angeles")
loc, _ := time.LoadLocation(viper.GetString("SERVER_TIMEZONE"))
time.Local = loc
if err := config.SetupConfig(); err != nil {
logger.Fatalf("config SetupConfig() error: %s", err)
}
masterDSN, replicaDSN := config.DbConfiguration()
if err := database.DbConnection(masterDSN, replicaDSN); err != nil {
logger.Fatalf("database DbConnection error: %s", err)
}
// later separate migration
migrations.Migrate()
// seed database
seeds.SeedUsers()
seeds.SeedRounds()
seeds.SeedPlayers()
router := routers.SetupRoute()
logger.Fatalf("%v", router.Run(config.ServerConfig()))
}