app: show unique ID in /api

This commit is contained in:
Peter Bourgon
2015-09-14 16:01:28 +02:00
parent effce2b07b
commit 822c09370e
2 changed files with 11 additions and 5 deletions

View File

@@ -16,8 +16,13 @@ import (
"github.com/weaveworks/scope/xfer"
)
// Set during buildtime.
var version = "dev"
var (
// Set at buildtime.
version = "dev"
// Set at runtime.
uniqueID = "0"
)
func main() {
var (
@@ -33,8 +38,8 @@ func main() {
}
rand.Seed(time.Now().UnixNano())
id := strconv.FormatInt(rand.Int63(), 16)
log.Printf("app starting, version %s, ID %s", version, id)
uniqueID = strconv.FormatInt(rand.Int63(), 16)
log.Printf("app starting, version %s, ID %s", version, uniqueID)
c := xfer.NewCollector(*window)
http.Handle("/", Router(c))

View File

@@ -121,11 +121,12 @@ func captureTopology(rep xfer.Reporter, f func(xfer.Reporter, topologyView, http
// APIDetails are some generic details that can be fetched from /api
type APIDetails struct {
ID string `json:"id"`
Version string `json:"version"`
}
func apiHandler(w http.ResponseWriter, r *http.Request) {
respondWith(w, http.StatusOK, APIDetails{Version: version})
respondWith(w, http.StatusOK, APIDetails{ID: uniqueID, Version: version})
}
// Topology option labels should tell the current state. The first item must