From 23f3b573419d0c9b795643284a1f8776682bc86f Mon Sep 17 00:00:00 2001 From: "Mikhail f. Shiryaev" Date: Wed, 3 Mar 2021 17:08:37 +0100 Subject: [PATCH] Set default Listeners only if Listen is omited --- cmd/carbonapi/config/init.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/carbonapi/config/init.go b/cmd/carbonapi/config/init.go index eee6f0487..7d95f12dc 100644 --- a/cmd/carbonapi/config/init.go +++ b/cmd/carbonapi/config/init.go @@ -246,6 +246,10 @@ func SetUpConfig(logger *zap.Logger, BuildVersion string) { } } + if len(Config.Listeners) == 0 { + Config.Listeners = append(Config.Listeners, Listener{Address: "localhost:8081"}) + } + for _, define := range Config.Define { if define.Name == "" { logger.Fatal("empty define name") @@ -321,9 +325,7 @@ func SetUpViper(logger *zap.Logger, configPath *string, viperPrefix string) { } viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) _ = viper.BindEnv("tz", "carbonapi_tz") - viper.SetDefault("listeners", []Listener{{ - Address: "localhost:8081", - }}) + viper.SetDefault("listeners", []Listener{}) viper.SetDefault("concurency", 20) viper.SetDefault("cache.type", "mem") viper.SetDefault("cache.size_mb", 0)