This is an automated email from the ASF dual-hosted git repository.

littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git


The following commit(s) were added to refs/heads/master by this push:
     new 976106e  [fix] add enableOnStart conditional judgment in syncer health 
init (#1290)
976106e is described below

commit 976106e29730648db22fd6e3f7825e51d4f8d530
Author: robotljw <[email protected]>
AuthorDate: Mon Mar 14 21:04:41 2022 +0800

    [fix] add enableOnStart conditional judgment in syncer health init (#1290)
---
 syncer/service/admin/health.go | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/syncer/service/admin/health.go b/syncer/service/admin/health.go
index 1068a29..65c10b7 100644
--- a/syncer/service/admin/health.go
+++ b/syncer/service/admin/health.go
@@ -22,6 +22,8 @@ import (
        "errors"
        "time"
 
+       "google.golang.org/grpc"
+
        "github.com/apache/servicecomb-service-center/client"
        "github.com/apache/servicecomb-service-center/pkg/log"
        pkgrpc "github.com/apache/servicecomb-service-center/pkg/rpc"
@@ -30,7 +32,6 @@ import (
        "github.com/apache/servicecomb-service-center/syncer/config"
        "github.com/apache/servicecomb-service-center/syncer/metrics"
        "github.com/apache/servicecomb-service-center/syncer/rpc"
-       "google.golang.org/grpc"
 )
 
 const (
@@ -62,10 +63,18 @@ type Peer struct {
 
 func init() {
        cfg := config.GetConfig()
-       if cfg.Sync == nil || len(cfg.Sync.Peers) <= 0 {
+       if cfg.Sync == nil {
                log.Warn("sync config is empty")
                return
        }
+       if !cfg.Sync.EnableOnStart {
+               log.Info("syncer is disabled")
+               return
+       }
+       if len(cfg.Sync.Peers) <= 0 {
+               log.Warn("peers parameter configuration is empty")
+               return
+       }
        peerInfos = make([]*PeerInfo, 0, len(cfg.Sync.Peers))
        for _, c := range cfg.Sync.Peers {
                if len(c.Endpoints) <= 0 {
@@ -83,6 +92,7 @@ func init() {
                }
        }
 }
+
 func Health() (*Resp, error) {
        if len(peerInfos) <= 0 {
                return nil, ErrConfigIsEmpty

Reply via email to