Update latency

This commit is contained in:
giongto35 2019-06-19 04:23:33 +08:00 committed by giongto35
parent 0bc8ce03f2
commit 1b39947541
3 changed files with 6 additions and 6 deletions

View file

@ -72,7 +72,11 @@ func initializeWorker() {
}
l.Close()
http.Handle("/metrics", promhttp.Handler())
if port == 9000 {
// only turn on metric for the first worker to avoid overlap
http.Handle("/metrics", promhttp.Handler())
}
http.ListenAndServe(":"+strconv.Itoa(port), nil)
}
}

View file

@ -2,7 +2,6 @@ package cws
import (
"encoding/json"
"fmt"
"log"
"sync"
"time"
@ -158,10 +157,6 @@ func (c *Client) Listen() {
}
wspacket := WSPacket{}
err = json.Unmarshal(rawMsg, &wspacket)
fmt.Println(wspacket)
if wspacket.ID == "checkLatency" {
fmt.Println("!!!!!!")
}
if err != nil {
continue

View file

@ -193,6 +193,7 @@ func (o *Server) findBestServerFromBrowser(client *BrowserClient) (string, error
// TODO: Add timeout
log.Println("Ping worker to get latency for ", client)
latencies := o.getLatencyMapFromBrowser(client)
log.Println("Latency map", latencies)
if len(latencies) == 0 {
return "", errors.New("No server found")