修改gate address bug
This commit is contained in:
parent
dccf1e0d69
commit
a68dbdd535
@ -9,17 +9,16 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
gateKey = "gate_config"
|
||||
gateAddress = "114.132.124.145"
|
||||
gatePort = "5100"
|
||||
gateKey = "gate_config"
|
||||
gateAddress1 = "114.132.124.145:5100"
|
||||
gateAddress2 = "114.132.124.145:5101"
|
||||
)
|
||||
|
||||
var Command *config.Command
|
||||
var Cfg *config.Common[GateConfig]
|
||||
|
||||
type GateConfig struct {
|
||||
Address string `json:"address"` // 网关地址
|
||||
Port string `json:"port"`
|
||||
Address []string `json:"address"` // 网关地址
|
||||
}
|
||||
|
||||
func initLog() {
|
||||
@ -43,8 +42,7 @@ func LoadConfig(GitCommit, GitBranch, BuildDate string) {
|
||||
if err = config.LoadSpecialConfig[GateConfig](rdb, gateKey, Cfg); err != nil {
|
||||
log.DebugF("load config:empty etcd key")
|
||||
Cfg.Special = &GateConfig{
|
||||
Address: gateAddress,
|
||||
Port: gatePort,
|
||||
Address: []string{gateAddress1, gateAddress2},
|
||||
}
|
||||
if bs, err := json.Marshal(&Cfg.Special); err == nil {
|
||||
err = rdb.Set(context.Background(), gateKey, string(bs), 0).Err()
|
||||
|
@ -65,7 +65,12 @@ func newGateService(serviceId int) *GateService {
|
||||
return nil
|
||||
}
|
||||
|
||||
wsAddress := fmt.Sprintf("%v:%v", config.Cfg.Special.Address, config.Cfg.Special.Port)
|
||||
addressPos := serviceId - config.Command.ServiceId
|
||||
if len(config.Cfg.Special.Address) <= addressPos {
|
||||
log.FatalF("Special address number must be greater than %d", addressPos)
|
||||
return nil
|
||||
}
|
||||
wsAddress := config.Cfg.Special.Address[addressPos]
|
||||
s.wss = ws.NewWsServer(wsAddress, s.WsOnMessage, s.WsOnDisconnect)
|
||||
s.bindService = userBindService.NewUserBindService(model.UserRedis, s.ServiceEtcd())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user