Return hostname in status page
This commit is contained in:
parent
a899f9e97a
commit
5a114bf622
12
blockbook.go
12
blockbook.go
@ -309,7 +309,17 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newInternalState(coin string, d *db.RocksDB) (*common.InternalState, error) {
|
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()) {
|
func tickAndDebounce(tickTime time.Duration, debounceTime time.Duration, input chan struct{}, f func()) {
|
||||||
|
|||||||
@ -27,6 +27,7 @@ type InternalState struct {
|
|||||||
mux sync.Mutex
|
mux sync.Mutex
|
||||||
|
|
||||||
Coin string `json:"coin"`
|
Coin string `json:"coin"`
|
||||||
|
Host string `json:"host"`
|
||||||
|
|
||||||
DbState uint32 `json:"dbState"`
|
DbState uint32 `json:"dbState"`
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ func (s *SocketIoServer) addressRedirect(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
type resAboutBlockbookPublic struct {
|
type resAboutBlockbookPublic struct {
|
||||||
Coin string `json:"coin"`
|
Coin string `json:"coin"`
|
||||||
About string `json:"about"`
|
Host string `json:"host"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
GitCommit string `json:"gitcommit"`
|
GitCommit string `json:"gitcommit"`
|
||||||
BuildTime string `json:"buildtime"`
|
BuildTime string `json:"buildtime"`
|
||||||
@ -153,6 +153,7 @@ type resAboutBlockbookPublic struct {
|
|||||||
LastBlockTime time.Time `json:"lastBlockTime"`
|
LastBlockTime time.Time `json:"lastBlockTime"`
|
||||||
InSyncMempool bool `json:"inSyncMempool"`
|
InSyncMempool bool `json:"inSyncMempool"`
|
||||||
LastMempoolTime time.Time `json:"lastMempoolTime"`
|
LastMempoolTime time.Time `json:"lastMempoolTime"`
|
||||||
|
About string `json:"about"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SocketIoServer) index(w http.ResponseWriter, r *http.Request) {
|
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()
|
ms, mt := s.is.GetMempoolSyncState()
|
||||||
a := resAboutBlockbookPublic{
|
a := resAboutBlockbookPublic{
|
||||||
Coin: s.is.Coin,
|
Coin: s.is.Coin,
|
||||||
About: blockbookAbout,
|
Host: s.is.Host,
|
||||||
Version: vi.Version,
|
Version: vi.Version,
|
||||||
GitCommit: vi.GitCommit,
|
GitCommit: vi.GitCommit,
|
||||||
BuildTime: vi.BuildTime,
|
BuildTime: vi.BuildTime,
|
||||||
@ -170,6 +171,7 @@ func (s *SocketIoServer) index(w http.ResponseWriter, r *http.Request) {
|
|||||||
LastBlockTime: st,
|
LastBlockTime: st,
|
||||||
InSyncMempool: ms,
|
InSyncMempool: ms,
|
||||||
LastMempoolTime: mt,
|
LastMempoolTime: mt,
|
||||||
|
About: blockbookAbout,
|
||||||
}
|
}
|
||||||
buf, err := json.MarshalIndent(a, "", " ")
|
buf, err := json.MarshalIndent(a, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user