@@ -14,7 +14,7 @@ import (
1414 "github.com/coder2z/g-saber/xdefer"
1515 "github.com/coder2z/g-saber/xjson"
1616 "github.com/coder2z/g-saber/xlog"
17- "github.com/coder2z/g-saber/xnet "
17+ "github.com/coder2z/g-saber/xtime "
1818 "github.com/coder2z/g-server/xapp"
1919 "github.com/coder2z/g-server/xcode"
2020 "github.com/coder2z/g-server/xmonitor"
@@ -26,12 +26,17 @@ import (
2626)
2727
2828type healthStats struct {
29- IP string `json:"ip"`
30- Hostname string `json:"hostname"`
31- Time string `json:"time"`
32- Err string `json:"err"`
33- Status string `json:"status"`
34- AppId string `json:"app_id"`
29+ IP string `json:"ip,omitempty"`
30+ Hostname string `json:"hostname,omitempty"`
31+ AppName string `json:"app_name,omitempty"`
32+ AppId string `json:"app_id,omitempty"`
33+ AppMode string `json:"app_mode,omitempty"`
34+ AppDebug bool `json:"app_debug"`
35+ AppVersion string `json:"app_version,omitempty"`
36+ GoVersion string `json:"go_version,omitempty"`
37+ Time string `json:"time,omitempty"`
38+ Err string `json:"err,omitempty"`
39+ Status string `json:"status,omitempty"`
3540}
3641
3742type h map [string ]func (w http.ResponseWriter , r * http.Request )
@@ -93,14 +98,18 @@ func init() {
9398 })
9499
95100 HandleFunc ("/debug/health" , func (w http.ResponseWriter , r * http.Request ) {
96- ip , _ := xnet .GetLocalIP ()
97101 serverStats := healthStats {
98- IP : ip ,
99- Hostname : xapp .HostName (),
100- AppId : xapp .AppId (),
101- Time : time .Now ().Format ("2006-01-02 15:04:05" ),
102- Status : "SUCCESS" ,
103- Err : "" ,
102+ IP : xapp .HostIP (),
103+ Hostname : xapp .HostName (),
104+ AppName : xapp .Name (),
105+ AppId : xapp .AppId (),
106+ AppMode : xapp .AppMode (),
107+ AppDebug : xapp .Debug (),
108+ AppVersion : xapp .AppVersion (),
109+ GoVersion : xapp .GoVersion (),
110+ Time : xtime .Now ().Format ("2006-01-02 15:04:05" ),
111+ Err : "" ,
112+ Status : "SUCCESS" ,
104113 }
105114 w .WriteHeader (200 )
106115 _ = xjson .NewEncoder (w ).Encode (serverStats )
0 commit comments