better
This commit is contained in:
parent
fbfda3b144
commit
222d71a8e0
1 changed files with 8 additions and 3 deletions
11
main.go
11
main.go
|
@ -138,14 +138,19 @@ func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// Is the inverter reachable?
|
// Is the inverter reachable?
|
||||||
|
var sgc *sungrowConn
|
||||||
for _, addr := range strings.Split(*inverterAddrs, ",") {
|
for _, addr := range strings.Split(*inverterAddrs, ",") {
|
||||||
sgc, err := dialSungrow(addr)
|
conn, err := dialSungrow(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Couldn't dial inverter: %v", err)
|
log.Printf("Couldn't dial inverter: %v", err)
|
||||||
}
|
}
|
||||||
defer sgc.Close()
|
sgc = conn
|
||||||
|
defer conn.Close()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if sgc == nil {
|
||||||
|
log.Fatal("Couldn't dial any addresses, aborting")
|
||||||
|
}
|
||||||
|
|
||||||
// HTTP setup
|
// HTTP setup
|
||||||
http.Handle("/metrics", promhttp.Handler())
|
http.Handle("/metrics", promhttp.Handler())
|
||||||
|
|
Loading…
Reference in a new issue