jo lesz az

This commit is contained in:
2026-03-22 19:35:24 +01:00
parent 3b997e3bab
commit 5dfe3ffa78
9 changed files with 834 additions and 880 deletions
+40
View File
@@ -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
}