You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ti...@apache.org on 2022/07/25 09:15:21 UTC
[servicecomb-kie] branch master updated: [fix]panic when use the default serf address (#248)
This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git
The following commit(s) were added to refs/heads/master by this push:
new 2ff76fd [fix]panic when use the default serf address (#248)
2ff76fd is described below
commit 2ff76fd2d869ef2715429f4eb2d5a076cbf2c661
Author: little-cui <su...@qq.com>
AuthorDate: Mon Jul 25 17:15:17 2022 +0800
[fix]panic when use the default serf address (#248)
* [fix]panic when use the default serf address
* [fix]panic when use the default serf address
---
server/pubsub/bus.go | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/server/pubsub/bus.go b/server/pubsub/bus.go
index 62a38e2..45a3118 100644
--- a/server/pubsub/bus.go
+++ b/server/pubsub/bus.go
@@ -57,17 +57,17 @@ func Init() {
once.Do(func() {
ac := agent.DefaultConfig()
sc := serf.DefaultConfig()
- if config.Configurations.ListenPeerAddr != "" {
- ac.BindAddr = config.Configurations.ListenPeerAddr
+ scmc := sc.MemberlistConfig
+ listenPeerAddr := config.Configurations.ListenPeerAddr
+ if listenPeerAddr != "" {
+ ac.BindAddr = listenPeerAddr
+ scmc.BindAddr, scmc.BindPort = splitHostPort(listenPeerAddr, scmc.BindAddr, scmc.BindPort)
}
- if config.Configurations.AdvertiseAddr != "" {
- ac.AdvertiseAddr = config.Configurations.AdvertiseAddr
+ advertiseAddr := config.Configurations.AdvertiseAddr
+ if advertiseAddr != "" {
+ ac.AdvertiseAddr = advertiseAddr
+ scmc.AdvertiseAddr, scmc.AdvertisePort = splitHostPort(advertiseAddr, scmc.AdvertiseAddr, scmc.AdvertisePort)
}
- memberConfig := sc.MemberlistConfig
- memberConfig.BindAddr, memberConfig.BindPort = splitHostPort(ac.BindAddr,
- memberConfig.BindAddr, memberConfig.BindPort)
- memberConfig.AdvertiseAddr, memberConfig.AdvertisePort = splitHostPort(ac.AdvertiseAddr,
- memberConfig.AdvertiseAddr, memberConfig.AdvertisePort)
if config.Configurations.NodeName != "" {
sc.NodeName = config.Configurations.NodeName
}
@@ -79,14 +79,6 @@ func Init() {
bus = &Bus{
agent: a,
}
- if config.Configurations.PeerAddr != "" {
- err := join([]string{config.Configurations.PeerAddr})
- if err != nil {
- openlog.Fatal("lost event message")
- } else {
- openlog.Info("join kie node:" + config.Configurations.PeerAddr)
- }
- }
})
}
@@ -115,6 +107,15 @@ func Start() {
openlog.Info("kie message bus started")
eh := &ClusterEventHandler{}
bus.agent.RegisterEventHandler(eh)
+
+ if config.Configurations.PeerAddr != "" {
+ err := join([]string{config.Configurations.PeerAddr})
+ if err != nil {
+ openlog.Fatal("lost event message")
+ } else {
+ openlog.Info("join kie node:" + config.Configurations.PeerAddr)
+ }
+ }
}
func join(addresses []string) error {
_, err := bus.agent.Join(addresses, false)