-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
57 lines (42 loc) · 1.06 KB
/
main.go
File metadata and controls
57 lines (42 loc) · 1.06 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
52
53
54
55
56
57
package main
import (
"fmt"
"pokemon-battle/cmd"
config "pokemon-battle/internal/configs"
"pokemon-battle/internal/infrastructure/logger"
util "pokemon-battle/internal/utils"
"sync"
)
func init() {
// Set Environment Type
envType, err := util.GetEnvironmentType()
if err != nil {
panic(fmt.Sprintf("Failed to set environment variable: %s", err.Error()))
}
config.EnvironmentType = envType
// Check Environment
if _, err := util.GetEnv.Check(); err != nil {
panic(err.Error())
}
// Initialize Logger
if err := logger.Initialize(config.EnvironmentType); err != nil {
panic(fmt.Sprintf("Failed to initialize logger: %v", err.Error()))
}
}
func main() {
defer util.PanicHandler("main.main", nil)
l := logger.Raw
l.Info("Welcome to pokemon-battle 🥊")
l.Info(fmt.Sprintf("Environment Type: %v", config.EnvironmentType))
var wg sync.WaitGroup
// ** Services
if util.IsFeatureActive("FEATURE_API") {
wg.Add(1)
cmd.Api(&wg)
}
if util.IsFeatureActive("FEATURE_BACKGROUND_FETCHER") {
wg.Add(1)
cmd.BackgroundFetcher(&wg)
}
wg.Wait()
}