-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
52 lines (39 loc) · 1004 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
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"log"
"os"
"com.thebeachmaster/golang-graphql-template/config"
"com.thebeachmaster/golang-graphql-template/drivers"
"com.thebeachmaster/golang-graphql-template/server"
)
func main() {
log.Println("Starting Server...")
var cfg *config.Config
if os.Getenv("SERVER_ENV") == "production" {
appConfigPath := "./config/config"
cfgFile, err := config.LoadConfig(appConfigPath)
if err != nil {
log.Fatalf("LoadConfig Error: %v", err)
}
pc, err := config.ParseConfig(cfgFile)
if err != nil {
log.Fatalf("ParseConfig Error: %v", err)
}
cfg = pc
} else {
lc, err := config.LoadEnvConfig()
if err != nil {
log.Fatalf("ParseConfig Error: %v", err)
}
cfg = lc
}
redisClient, err := drivers.NewRedisDBClient(cfg)
if err != nil {
log.Printf("failed to connect to redis due to: %v\n", err)
}
defer redisClient.Close()
server := server.NewServer(cfg /**dbclient*/, redisClient)
if err = server.Run(); err != nil {
log.Fatal(err)
}
}