-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
51 lines (40 loc) · 1.07 KB
/
main.go
File metadata and controls
51 lines (40 loc) · 1.07 KB
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 (
"log"
"github.com/TheDevExperiment/server/internal/cache"
"github.com/TheDevExperiment/server/internal/db"
logger "github.com/TheDevExperiment/server/internal/log"
"github.com/TheDevExperiment/server/router"
"github.com/spf13/viper"
)
func startMongo() {
err := db.Connect()
if err != nil {
logger.Fatal(err)
}
}
func setupViper() {
// Set the file name of the configurations file
viper.SetConfigName("config")
// Set the path to look for the configurations file
viper.AddConfigPath(".")
// Enable VIPER to read Environment Variables
viper.AutomaticEnv()
viper.SetConfigType("yml")
if err := viper.ReadInConfig(); err != nil {
log.Fatalf("Error reading config file, %s", err)
}
}
func startLogger() {
// TODO: choose logger acc to env ie prod/dev/stag
// default is dev
logger.InitZapLogger()
}
func main() {
setupViper() // FYI- Be careful while adding anything above this.
startLogger() // start logger
startMongo() // start mongo db
cache.GetClient() // fire up redis cache
r := router.SetupRouter()
r.Run(":8080")
}