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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user