Limit telemetry and proxy to run command (#5047)

This commit is contained in:
andig 2022-11-04 10:30:35 +01:00
parent 722a17d548
commit 03c04b1a67
2 changed files with 19 additions and 19 deletions

View file

@ -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 {

View file

@ -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)