game/server/db/config/config.go

39 lines
826 B
Go
Raw Normal View History

2025-05-31 23:34:58 +08:00
package config
import (
"game/common/config"
2025-06-06 00:09:10 +08:00
"game/common/constant"
2025-05-31 23:34:58 +08:00
"github.com/fox/fox/db"
"github.com/fox/fox/log"
)
var Command *config.Command
var Cfg *config.Common[DbConfig]
type DbConfig struct {
}
func InitLog() {
log.Open("./log/db.log", log.DebugL)
log.Info("")
log.Info("")
log.Info("")
log.Info("-----init log success-----")
}
func LoadConfig(GitCommit, GitBranch, BuildDate string) {
Command = config.ParseCommand()
2025-06-06 00:09:10 +08:00
rdb, err := db.InitRedis(Command.RedisPassword, Command.RedisHost, Command.RedisPort, constant.Redis0Config)
2025-05-31 23:34:58 +08:00
if err != nil {
log.Error(err.Error())
return
}
defer func() { _ = rdb.Close() }()
Cfg, err = config.LoadCommonConfig[DbConfig](rdb, GitCommit, GitBranch, BuildDate)
if err != nil {
log.Error(err.Error())
return
}
log.DebugF("load common config success")
}