mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-06-27 11:28:51 +02:00
Store connected viewers in Prometheus and serve this amount
This commit is contained in:
@ -84,3 +84,11 @@ func staticHandler() http.Handler {
|
||||
staticFs := http.FileServer(pkger.Dir("/web/static"))
|
||||
return http.StripPrefix("/static/", staticFs)
|
||||
}
|
||||
|
||||
func statisticsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Display connected users stats
|
||||
enc := json.NewEncoder(w)
|
||||
enc.Encode(struct {
|
||||
ConnectedViewers int
|
||||
}{int(monitoring.GetGaugeValue(monitoring.WebRTCConnectedSessions))})
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ func Serve(rSdpChan chan webrtc.SessionDescription, lSdpChan chan webrtc.Session
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", viewerHandler)
|
||||
mux.Handle("/static/", staticHandler())
|
||||
mux.HandleFunc("/_stats/", statisticsHandler)
|
||||
log.Printf("HTTP server listening on %s", cfg.ListenAddress)
|
||||
log.Fatal(http.ListenAndServe(cfg.ListenAddress, mux))
|
||||
}
|
||||
|
Reference in New Issue
Block a user