Skip to content

Commit

Permalink
feat: monitor cmdline
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyoucao577 committed Mar 19, 2020
1 parent 894c8d1 commit 7f64893
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions integration/cmd/osrm-ranking/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"flag"
"net/http"
"os"
"strconv"
"strings"
"time"
Expand All @@ -24,6 +25,7 @@ func main() {
// monitor
upClock := time.Now()
monitorContents := newMonitorContents()
monitorContents.CmdlineArgs = os.Args
monitorContents.TrafficCacheMonitorContents.Name = "traffic cache(indexed by edge)"

// prepare historical speeds if available
Expand Down Expand Up @@ -63,6 +65,8 @@ func main() {

//start http listening
mux := http.NewServeMux()

//monitor service
mux.HandleFunc("/monitor/", func(w http.ResponseWriter, req *http.Request) {
monitorContents.UpTime = jsonDuration(time.Now().Sub(upClock))

Expand Down
3 changes: 2 additions & 1 deletion integration/cmd/osrm-ranking/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type monitorContents struct {
HistoricalSpeedMonitorContents *historicalSpeedMonitorContents `json:"historical_speed"`
TrafficCacheMonitorContents *trafficCacheMonitorContents `json:"traffic_cache"`
WayID2NodeIDsMonitorContents *wayID2NodeIDsMonitorContents `json:"wayid2nodeids"`
CmdlineArgs []string `json:"cmdline"`
}

type trafficCacheMonitorContents struct {
Expand All @@ -33,7 +34,7 @@ type historicalSpeedMonitorContents struct {

func newMonitorContents() *monitorContents {
return &monitorContents{
0, &historicalSpeedMonitorContents{}, &trafficCacheMonitorContents{}, &wayID2NodeIDsMonitorContents{},
0, &historicalSpeedMonitorContents{}, &trafficCacheMonitorContents{}, &wayID2NodeIDsMonitorContents{}, nil,
}
}

Expand Down

0 comments on commit 7f64893

Please sign in to comment.