/
main.go
46 lines (36 loc) · 1.11 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
package main
import (
"github.com/0-u-0/dugon-signal-server/libs"
"github.com/spf13/viper"
"log"
)
var lastCompile string
func main() {
defer func() {
libs.ReleaseLoggerModule()
}()
viper.SetConfigName("config")
viper.SetConfigType("toml")
viper.AddConfigPath(".")
viper.AddConfigPath("/etc/dugon-signal-server/")
err := viper.ReadInConfig()
if err != nil {
log.Fatalf("Fatal error config file: %s \n", err)
}
logLevel := viper.GetString("log_level")
logToFile := viper.GetBool("log_to_file")
logFilePath := viper.GetString("log_file_path")
logErrorPath := viper.GetString("err_log_file_path")
libs.InitGlobalLog()
libs.LoadLoggerModule(logLevel, logToFile, logFilePath, logErrorPath)
port := viper.GetInt("port")
httpsEnable := viper.GetBool("https_enable")
cert := viper.GetString("cert")
key := viper.GetString("key")
natsUrls := viper.GetStringSlice("nats_urls")
libs.Log.Infof("Compiled : %s ->", lastCompile)
libs.Log.Info("Config ->", viper.AllSettings())
clientGroup := libs.NewClientGroup(natsUrls)
go clientGroup.Run()
libs.InitWsServer(clientGroup, port, httpsEnable, cert, key)
}