game/server/client/config/config.go
2025-06-15 20:28:28 +08:00

45 lines
991 B
Go

package config
import (
"game/common/config"
"game/common/constant"
"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
var ClientCfg = &ClientConfig{}
type ClientConfig struct {
Address []string `json:"address"` // 网关地址
}
func initLog() {
log.Open("./log/client.log", log.DebugL)
}
func LoadConfig(GitCommit, GitBranch, BuildDate string) {
Command = config.ParseCommand()
initLog()
rdb, err := db.InitRedis(Command.RedisPassword, Command.RedisHost, Command.RedisPort, constant.Redis0Config)
if err != nil {
log.Error(err.Error())
return
}
defer func() { _ = rdb.Close() }()
Cfg, err = config.LoadCommonConfig(rdb, GitCommit, GitBranch, BuildDate)
if err != nil {
log.Error(err.Error())
return
}
ClientCfg.Address = append(ClientCfg.Address, gateAddress1, gateAddress2)
log.DebugF("load common config success")
}