-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
60 lines (48 loc) · 1.35 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"os"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"github.com/Icerzack/excaliroom/cmd"
"github.com/Icerzack/excaliroom/internal/rest"
"github.com/Icerzack/excaliroom/internal/utils"
)
func main() {
configPath := os.Getenv("CONFIG_PATH")
appConfig, err := cmd.ParseConfig(configPath)
if err != nil {
return
}
var level zapcore.Level
var writeToFiles bool
switch appConfig.Logging.Level {
case "INFO":
level = zap.InfoLevel
case "DEBUG":
level = zap.DebugLevel
}
if appConfig.Logging.WriteToFile {
writeToFiles = true
}
logger, err := utils.NewCustomLogger(level, writeToFiles)
if err != nil {
fmt.Println("unable to create logger", err)
return
}
restApp := rest.NewRest(&rest.Config{
Port: appConfig.Apps.Rest.Port,
JwtValidationURL: appConfig.Apps.Rest.Validation.JWTValidationURL,
JwtHeaderName: appConfig.Apps.Rest.Validation.JWTHeaderName,
BoardValidationURL: appConfig.Apps.Rest.Validation.BoardValidationURL,
UsersStorageType: appConfig.Storage.Users.Type,
RoomsStorageType: appConfig.Storage.Rooms.Type,
CacheType: appConfig.Cache.Type,
CacheTTL: appConfig.Cache.TTL,
Logger: logger,
})
appsManager := cmd.NewAppsManager(logger)
appsManager.Register(cmd.RestApp, restApp)
appsManager.RunAll()
appsManager.WaitForShutdown()
}