From 719dc43af14142ca1fb199882366b46aa4189e1f Mon Sep 17 00:00:00 2001 From: "ruitao.liu" Date: Thu, 10 Sep 2020 16:24:09 +0800 Subject: [PATCH] modify elastic urls from string to array. --- weed/command/scaffold.go | 6 +++++- weed/filer/elastic/v7/elastic_store.go | 9 ++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/weed/command/scaffold.go b/weed/command/scaffold.go index 7ced118ca..800bc6029 100644 --- a/weed/command/scaffold.go +++ b/weed/command/scaffold.go @@ -176,7 +176,11 @@ database = "seaweedfs" [elastic7] enabled = false -servers = "http://localhost1:9200,http://localhost2:9200,http://localhost3:9200" +servers = [ + "http://localhost1:9200", + "http://localhost2:9200", + "http://localhost3:9200", +] username = "" password = "" sniff_enabled = false diff --git a/weed/filer/elastic/v7/elastic_store.go b/weed/filer/elastic/v7/elastic_store.go index 7696d6b1f..5750b2fb8 100644 --- a/weed/filer/elastic/v7/elastic_store.go +++ b/weed/filer/elastic/v7/elastic_store.go @@ -68,13 +68,8 @@ func (store *ElasticStore) Initialize(configuration weed_util.Configuration, pre } func (store *ElasticStore) initialize(configuration weed_util.Configuration, prefix string) (options []elastic.ClientOptionFunc) { - configuration.SetDefault(prefix+"servers", "http://localhost:9200") - servers := configuration.GetString(prefix + "servers") - url := make([]string, 0) - for _, v := range strings.Split(servers, ",") { - url = append(url, v) - } - options = append(options, elastic.SetURL(url...)) + servers := configuration.GetStringSlice(prefix + "servers") + options = append(options, elastic.SetURL(servers...)) username := configuration.GetString(prefix + "username") password := configuration.GetString(prefix + "password") if username != "" && password != "" {