Compare commits

...

3 Commits

3 changed files with 9 additions and 15 deletions

View File

@ -119,10 +119,6 @@ func (pe *prometheusExporter) loop(ctx context.Context) {
case nm := <-pe.registerChan: case nm := <-pe.registerChan:
var nextmetrics map[string]*prometheusMetricDesc var nextmetrics map[string]*prometheusMetricDesc
if collector != nil { if collector != nil {
if collector.metrics[nm.key] != nil {
break
}
nextmetrics = collector.metrics nextmetrics = collector.metrics
prometheus.Unregister(collector) prometheus.Unregister(collector)
nextmetrics[nm.key] = nm nextmetrics[nm.key] = nm
@ -132,12 +128,14 @@ func (pe *prometheusExporter) loop(ctx context.Context) {
} }
} }
collector = &prometheusCollector{ nextcollector := &prometheusCollector{
metrics: nextmetrics, metrics: nextmetrics,
} }
if err := prometheus.Register(collector); err != nil { if err := prometheus.Register(nextcollector); err != nil {
logger.Error("prometheus register err :", *nm, err) logger.Error("prometheus register err :", *nm, err)
} else {
collector = nextcollector
} }
} }
} }

View File

@ -3,8 +3,6 @@ package gocommon
import ( import (
"encoding/json" "encoding/json"
"os" "os"
"path"
"strings"
"time" "time"
"repositories.action2quare.com/ayo/gocommon/flagx" "repositories.action2quare.com/ayo/gocommon/flagx"
@ -18,10 +16,10 @@ func configFilePath() string {
configfilepath = *configfileflag configfilepath = *configfileflag
} }
if !strings.HasPrefix(configfilepath, "/") { // if !strings.HasPrefix(configfilepath, "/") {
exe, _ := os.Executable() // exe, _ := os.Executable()
configfilepath = path.Join(path.Dir(exe), configfilepath) // configfilepath = path.Join(path.Dir(exe), configfilepath)
} // }
return configfilepath return configfilepath
} }

View File

@ -297,7 +297,7 @@ func (ws *WebsocketHandler) mainLoop(ctx context.Context) {
defer func() { defer func() {
for _, conn := range entireConns { for _, conn := range entireConns {
ws.Call(conn.sender, ClientDisconnected, nil) ws.ClientDisconnected(conn)
conn.Close() conn.Close()
} }
}() }()
@ -459,11 +459,9 @@ func (ws *WebsocketHandler) mainLoop(ctx context.Context) {
case c := <-ws.connInOutChan: case c := <-ws.connInOutChan:
if c.Conn == nil { if c.Conn == nil {
delete(entireConns, c.sender.Accid.Hex()) delete(entireConns, c.sender.Accid.Hex())
logger.Println("ClientDisconnected :", c.sender.Alias)
go ws.ClientDisconnected(c) go ws.ClientDisconnected(c)
} else { } else {
entireConns[c.sender.Accid.Hex()] = c entireConns[c.sender.Accid.Hex()] = c
logger.Println("ClientConnected :", c.sender.Alias)
go ws.ClientConnected(c) go ws.ClientConnected(c)
} }