game/server/client/config/config.go

42 lines
946 B
Go
Raw Normal View History

2025-05-29 17:54:47 +08:00
package config
import (
"game/common/config"
"github.com/fox/fox/db"
"github.com/fox/fox/log"
)
const (
gateAddress1 = "114.132.124.145:5100"
gateAddress2 = "114.132.124.145:5101"
)
var Command *config.Command
var Cfg *config.Common[ClientConfig]
type ClientConfig struct {
Address []string `json:"address"` // 网关地址
}
func initLog() {
2025-05-30 23:33:38 +08:00
log.Open("./log/client.log", log.DebugL)
2025-05-29 17:54:47 +08:00
}
func LoadConfig(GitCommit, GitBranch, BuildDate string) {
Command = config.ParseCommand()
initLog()
rdb, err := db.InitRedis(Command.RedisPassword, Command.RedisHost, Command.RedisPort, 0)
if err != nil {
log.Error(err.Error())
return
}
defer func() { _ = rdb.Close() }()
Cfg, err = config.LoadCommonConfig[ClientConfig](rdb, GitCommit, GitBranch, BuildDate)
if err != nil {
log.Error(err.Error())
return
}
Cfg.Special.Address = append(Cfg.Special.Address, gateAddress1, gateAddress2)
log.DebugF("load common config success")
}