fix config server address declaration
This commit is contained in:
1 parent
04ceb5f4fa
commit
0259cf84ce
2 files changed
+20
-5
No files matched your search
@@ -58,12 +58,18 @@ func main() {
|
||||
cfg := config.Get().(*conf.Configuration)
|
||||
handlers := helper.GetHandlers()
|
||||
endpoints := backend.GetEndpoints(cfg.ModuleName, handlers)
|
||||
address := cfg.WS.Grpc
|
||||
ip, err := getOutboundIp()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
address.IP = ip
|
||||
declaration := structure.BackendDeclaration{
|
||||
ModuleName: cfg.ModuleName,
|
||||
Version: version,
|
||||
LibVersion: bootstrap.LibraryVersion,
|
||||
Endpoints: endpoints,
|
||||
Address: cfg.WS.Grpc,
|
||||
Address: address,
|
||||
}
|
||||
|
||||
model.DbClient.ReceiveConfiguration(cfg.Database)
|
||||
@@ -99,7 +105,7 @@ func initMultiplexer(addressConfiguration structure.AddressConfiguration) (net.L
|
||||
raftListener := m.Match(cmux.Any())
|
||||
|
||||
go func() {
|
||||
if err := m.Serve(); !strings.Contains(err.Error(), "use of closed network connection") {
|
||||
if err := m.Serve(); err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
|
||||
log.Fatalf(codes.InitCmuxError, "serve cmux: %v", err)
|
||||
}
|
||||
}()
|
||||
@@ -198,3 +204,12 @@ func onShutdown(ctx context.Context, sig os.Signal) {
|
||||
log.Info(codes.RaftShutdownInfo, "raft shutdown success")
|
||||
}
|
||||
}
|
||||
|
||||
func getOutboundIp() (string, error) {
|
||||
conn, err := net.Dial("udp", "9.9.9.9:80")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer conn.Close()
|
||||
return conn.LocalAddr().(*net.UDPAddr).IP.To4().String(), nil
|
||||
}
|
||||
+3
-3
@@ -38,17 +38,17 @@ func (e validationSchemaError) Error() string {
|
||||
return resp
|
||||
}
|
||||
|
||||
func (s configService) GetCompiledConfig(moduleName string, state state.ReadonlyState) (map[string]interface{}, error) {
|
||||
func (cs configService) GetCompiledConfig(moduleName string, state state.ReadonlyState) (map[string]interface{}, error) {
|
||||
module := state.Modules().GetByName(moduleName)
|
||||
if module == nil {
|
||||
return nil, errors.Errorf("module with name %s not found", moduleName)
|
||||
}
|
||||
config := state.Configs().GetActiveByModuleId(module.Id)
|
||||
if config == nil {
|
||||
return nil, errors.Errorf("no active configs for moduleId %s", module.Id)
|
||||
return nil, errors.Errorf("no active configs for moduleName %s, moduleId %s", moduleName, module.Id)
|
||||
}
|
||||
|
||||
return s.CompileConfig(config.Data, state, config.CommonConfigs...), nil
|
||||
return cs.CompileConfig(config.Data, state, config.CommonConfigs...), nil
|
||||
}
|
||||
|
||||
func (configService) CompileConfig(data map[string]interface{}, state state.ReadonlyState, commonConfigsIds ...string) map[string]interface{} {
|
||||
|
||||
Reference in new issue
Block a user