Return hostname in status page

pull/7/head
Martin Boehm 2018-05-30 14:44:40 +02:00
parent a899f9e97a
commit 5a114bf622
3 changed files with 16 additions and 3 deletions

View File

@ -309,7 +309,17 @@ func main() {
}
func newInternalState(coin string, d *db.RocksDB) (*common.InternalState, error) {
return d.LoadInternalState(coin)
is, err := d.LoadInternalState(coin)
if err != nil {
return nil, err
}
name, err := os.Hostname()
if err != nil {
glog.Error("get hostname ", err)
} else {
is.Host = name
}
return is, nil
}
func tickAndDebounce(tickTime time.Duration, debounceTime time.Duration, input chan struct{}, f func()) {

View File

@ -27,6 +27,7 @@ type InternalState struct {
mux sync.Mutex
Coin string `json:"coin"`
Host string `json:"host"`
DbState uint32 `json:"dbState"`

View File

@ -144,7 +144,7 @@ func (s *SocketIoServer) addressRedirect(w http.ResponseWriter, r *http.Request)
type resAboutBlockbookPublic struct {
Coin string `json:"coin"`
About string `json:"about"`
Host string `json:"host"`
Version string `json:"version"`
GitCommit string `json:"gitcommit"`
BuildTime string `json:"buildtime"`
@ -153,6 +153,7 @@ type resAboutBlockbookPublic struct {
LastBlockTime time.Time `json:"lastBlockTime"`
InSyncMempool bool `json:"inSyncMempool"`
LastMempoolTime time.Time `json:"lastMempoolTime"`
About string `json:"about"`
}
func (s *SocketIoServer) index(w http.ResponseWriter, r *http.Request) {
@ -161,7 +162,7 @@ func (s *SocketIoServer) index(w http.ResponseWriter, r *http.Request) {
ms, mt := s.is.GetMempoolSyncState()
a := resAboutBlockbookPublic{
Coin: s.is.Coin,
About: blockbookAbout,
Host: s.is.Host,
Version: vi.Version,
GitCommit: vi.GitCommit,
BuildTime: vi.BuildTime,
@ -170,6 +171,7 @@ func (s *SocketIoServer) index(w http.ResponseWriter, r *http.Request) {
LastBlockTime: st,
InSyncMempool: ms,
LastMempoolTime: mt,
About: blockbookAbout,
}
buf, err := json.MarshalIndent(a, "", " ")
if err != nil {