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