From 49d6829fa8351542256be4fd7a290804b34b83b2 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 19 May 2021 14:05:18 -0700 Subject: [PATCH] add --serve flag to all benchmarks --- api/api.go | 6 +++--- cli/analyze.go | 6 ------ cli/flags.go | 4 ++++ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/api/api.go b/api/api.go index d6b5094a..fef6b360 100644 --- a/api/api.go +++ b/api/api.go @@ -247,8 +247,8 @@ func (s *Server) handleDownloadJSON(w http.ResponseWriter, req *http.Request) { enc.Encode(ops) } -// handleRootAPI handles requests to `/v1`. -func (s *Server) handleRootAPI(w http.ResponseWriter, req *http.Request) { +// handleStop handles requests to `/v1/stop`, stops the service. +func (s *Server) handleStop(w http.ResponseWriter, req *http.Request) { if req.Method == http.MethodDelete { w.WriteHeader(200) w.Write([]byte(`bye...`)) @@ -273,8 +273,8 @@ func NewBenchmarkMonitor(listenAddr string) *Server { s.ctx, s.cancel = context.WithCancel(context.Background()) mux := http.NewServeMux() + mux.HandleFunc("/v1/stop", s.handleStop) mux.HandleFunc("/v1/status", s.handleStatus) - mux.HandleFunc("/v1", s.handleRootAPI) mux.HandleFunc("/v1/aggregated", s.handleAggregated) mux.HandleFunc("/v1/operations/json", s.handleDownloadJSON) mux.HandleFunc("/v1/operations", s.handleDownloadZst) diff --git a/cli/analyze.go b/cli/analyze.go index 27159290..901e0e86 100644 --- a/cli/analyze.go +++ b/cli/analyze.go @@ -80,12 +80,6 @@ var analyzeFlags = []cli.Flag{ Name: "analyze.v", Usage: "Display additional analysis data.", }, - cli.StringFlag{ - Name: serverFlagName, - Usage: "When running benchmarks open a webserver on this ip:port and keep it running afterwards.", - Value: "", - Hidden: true, - }, } var analyzeCmd = cli.Command{ diff --git a/cli/flags.go b/cli/flags.go index c531aec2..a0533212 100644 --- a/cli/flags.go +++ b/cli/flags.go @@ -53,6 +53,10 @@ var globalFlags = []cli.Flag{ Name: "autocompletion", Usage: "install auto-completion for your shell", }, + cli.StringFlag{ + Name: serverFlagName, + Usage: "When running benchmarks open a webserver to fetch results remotely, eg: localhost:7762", + }, } var profileFlags = []cli.Flag{