From fa098f1af0d7f68fb31a129f94c077c6343eb978 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Thu, 17 Mar 2022 11:04:11 -0700 Subject: [PATCH] Show version on main monitoring page with link to source Signed-off-by: Derek Collison --- server/monitor.go | 44 +++++++++++++++++++++++++++++++------------- server/server.go | 2 +- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/server/monitor.go b/server/monitor.go index 85604cf0..02e88850 100644 --- a/server/monitor.go +++ b/server/monitor.go @@ -1241,20 +1241,36 @@ func (s *Server) HandleRoot(w http.ResponseWriter, r *http.Request) { s.mu.Lock() s.httpReqStats[RootPath]++ s.mu.Unlock() + + // Calculate source url. If git set go directly to that tag, otherwise just main. + var srcUrl string + if gitCommit == _EMPTY_ { + srcUrl = "https://github.com/nats-io/nats-server" + } else { + srcUrl = fmt.Sprintf("https://github.com/nats-io/nats-server/tree/%s", gitCommit) + } + fmt.Fprintf(w, ` - - - - - - -
+ + + + + + + + v%s + + +
General JetStream Connections @@ -1267,6 +1283,8 @@ func (s *Server) HandleRoot(w http.ResponseWriter, r *http.Request) { Help `, + srcUrl, + VERSION, s.basePath(VarzPath), s.basePath(JszPath), s.basePath(ConnzPath), diff --git a/server/server.go b/server/server.go index 96474680..b9776532 100644 --- a/server/server.go +++ b/server/server.go @@ -1607,7 +1607,7 @@ func (s *Server) Start() { s.Noticef("Starting nats-server") gc := gitCommit - if gc == "" { + if gc == _EMPTY_ { gc = "not set" }