From 03c04b1a6762693ec946c863ba73716842ac4920 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 4 Nov 2022 10:30:35 +0100 Subject: [PATCH] Limit telemetry and proxy to run command (#5047) --- cmd/root.go | 19 +++++++++++++++++++ cmd/setup.go | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 70a5bd18d..922872e20 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -15,10 +15,12 @@ import ( "github.com/evcc-io/evcc/core" "github.com/evcc-io/evcc/push" "github.com/evcc-io/evcc/server" + "github.com/evcc-io/evcc/server/modbus" "github.com/evcc-io/evcc/server/updater" "github.com/evcc-io/evcc/util" "github.com/evcc-io/evcc/util/pipe" "github.com/evcc-io/evcc/util/sponsor" + "github.com/evcc-io/evcc/util/telemetry" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/spf13/cobra" @@ -149,6 +151,23 @@ func runRoot(cmd *cobra.Command, args []string) { err = configureEnvironment(cmd, conf) } + // setup telemetry + if err == nil { + telemetry.Create(conf.Plant) + if conf.Telemetry { + err = telemetry.Enable(true) + } + } + + // setup modbus proxy + if err == nil { + for _, cfg := range conf.ModbusProxy { + if err = modbus.StartProxy(cfg.Port, cfg.Settings, cfg.ReadOnly); err != nil { + break + } + } + } + // setup site and loadpoints var site *core.Site if err == nil { diff --git a/cmd/setup.go b/cmd/setup.go index 38260311c..30c942ee4 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -20,7 +20,6 @@ import ( "github.com/evcc-io/evcc/server" "github.com/evcc-io/evcc/server/db" "github.com/evcc-io/evcc/server/db/settings" - "github.com/evcc-io/evcc/server/modbus" "github.com/evcc-io/evcc/tariff" "github.com/evcc-io/evcc/util" "github.com/evcc-io/evcc/util/locale" @@ -28,7 +27,6 @@ import ( "github.com/evcc-io/evcc/util/pipe" "github.com/evcc-io/evcc/util/request" "github.com/evcc-io/evcc/util/sponsor" - "github.com/evcc-io/evcc/util/telemetry" "github.com/libp2p/zeroconf/v2" "github.com/samber/lo" "github.com/spf13/cobra" @@ -94,28 +92,11 @@ func configureEnvironment(cmd *cobra.Command, conf config) (err error) { err = configureDatabase(conf.Database) } - // setup telemetry - if err == nil { - telemetry.Create(conf.Plant) - if conf.Telemetry { - err = telemetry.Enable(true) - } - } - // setup mqtt client listener if err == nil && conf.Mqtt.Broker != "" { err = configureMQTT(conf.Mqtt) } - // setup modbus proxy listeners - if err == nil { - for _, cfg := range conf.ModbusProxy { - if err = modbus.StartProxy(cfg.Port, cfg.Settings, cfg.ReadOnly); err != nil { - break - } - } - } - // setup javascript VMs if err == nil { err = configureJavascript(conf.Javascript)