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

@@ -4,20 +4,8 @@ import (
"log"
"github.com/googollee/go-socket.io"
"github.com/prometheus/client_golang/prometheus"
)
var (
clientsGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "clients",
Help: "Clients",
})
)
func init() {
prometheus.MustRegister(clientsGauge)
}
type ViewPort struct {
Rows uint
Cols uint
@@ -35,7 +23,6 @@ func (c *Client) ResizeViewPort(cols, rows uint) {
}
func NewClient(so socketio.Socket, session *Session) *Client {
clientsGauge.Inc()
so.Join(session.Id)
c := &Client{so: so, Id: so.Id()}
@@ -67,7 +54,6 @@ func NewClient(so socketio.Socket, session *Session) *Client {
})
so.On("disconnection", func() {
clientsGauge.Dec()
// Client has disconnected. Remove from session and recheck terminal sizes.
for i, cl := range session.clients {
if cl.Id == c.Id {
@@ -83,6 +69,7 @@ func NewClient(so socketio.Socket, session *Session) *Client {
instance.ResizeTerminal(vp.Cols, vp.Rows)
}
}
setGauges()
})
return c
}