mirror of
https://github.com/skidoodle/ncore-stats.git
synced 2026-04-27 23:37:36 +02:00
jo lesz az
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func loadConfig() *Configuration {
|
||||
_ = godotenv.Load()
|
||||
logrus.SetFormatter(&logrus.TextFormatter{FullTimestamp: true, ForceColors: true})
|
||||
|
||||
cfg := &Configuration{}
|
||||
cfg.Ncore.Nick = os.Getenv("NICK")
|
||||
cfg.Ncore.Pass = os.Getenv("PASS")
|
||||
if cfg.Ncore.Nick == "" || cfg.Ncore.Pass == "" {
|
||||
logrus.Fatal("NICK and PASS environment variables are required")
|
||||
}
|
||||
|
||||
cfg.ServerPort = os.Getenv("SERVER_PORT")
|
||||
if cfg.ServerPort == "" {
|
||||
cfg.ServerPort = defaultPort
|
||||
} else if !strings.HasPrefix(cfg.ServerPort, ":") {
|
||||
cfg.ServerPort = ":" + cfg.ServerPort
|
||||
}
|
||||
|
||||
cfg.DatabasePath = os.Getenv("DATABASE_PATH")
|
||||
if cfg.DatabasePath == "" {
|
||||
cfg.DatabasePath = defaultDbFolder
|
||||
}
|
||||
|
||||
lvl, _ := logrus.ParseLevel(os.Getenv("LOG_LEVEL"))
|
||||
if lvl == 0 {
|
||||
lvl = logrus.InfoLevel
|
||||
}
|
||||
logrus.SetLevel(lvl)
|
||||
return cfg
|
||||
}
|
||||
Reference in New Issue
Block a user