game/server/client/config/config.go

45 lines
991 B
Go
Raw Normal View History

2025-05-29 17:54:47 +08:00
package config
import (
"game/common/config"
2025-06-06 00:09:10 +08:00
"game/common/constant"
2025-05-29 17:54:47 +08:00
"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
2025-06-15 20:28:28 +08:00
var Cfg *config.Common
var ClientCfg = &ClientConfig{}
2025-05-29 17:54:47 +08:00
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()
2025-06-06 00:09:10 +08:00
rdb, err := db.InitRedis(Command.RedisPassword, Command.RedisHost, Command.RedisPort, constant.Redis0Config)
2025-05-29 17:54:47 +08:00
if err != nil {
log.Error(err.Error())
return
}
defer func() { _ = rdb.Close() }()
2025-06-15 20:28:28 +08:00
Cfg, err = config.LoadCommonConfig(rdb, GitCommit, GitBranch, BuildDate)
2025-05-29 17:54:47 +08:00
if err != nil {
log.Error(err.Error())
return
}
2025-06-15 20:28:28 +08:00
ClientCfg.Address = append(ClientCfg.Address, gateAddress1, gateAddress2)
2025-05-29 17:54:47 +08:00
log.DebugF("load common config success")
}