1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-10-05 09:53:21 +08:00

Fixes prometheus gauges

Fix session close. Now PWD gets disconnected from network before
deleting it.
This commit is contained in:
Jonathan Leibiusky (@xetorthio)
2016-12-17 11:41:24 -08:00
parent 70eaf37d4b
commit 93226e30ff
4 changed files with 48 additions and 33 deletions

View File

@@ -11,22 +11,10 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/prometheus/client_golang/prometheus"
)
var rw sync.Mutex
var (
instancesGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "instances",
Help: "Instances",
})
)
func init() {
prometheus.MustRegister(instancesGauge)
}
type Instance struct {
session *Session `json:"-"`
Name string `json:"name"`
@@ -102,7 +90,7 @@ func NewInstance(session *Session) (*Instance, error) {
wsServer.BroadcastTo(session.Id, "new instance", instance.Name, instance.IP, instance.Hostname)
instancesGauge.Inc()
setGauges()
return instance, nil
}
@@ -156,7 +144,7 @@ func DeleteInstance(session *Session, instance *Instance) error {
wsServer.BroadcastTo(session.Id, "delete instance", instance.Name)
instancesGauge.Dec()
setGauges()
return err
}