Commit 3fe09bd6 authored by szh's avatar szh

nodeinfo 改为实时获取

parent 56f89321
...@@ -343,9 +343,22 @@ func GetAbsPath(key string) string { ...@@ -343,9 +343,22 @@ func GetAbsPath(key string) string {
if len(params) == 11 { if len(params) == 11 {
if params[10] != "" { if params[10] != "" {
return path.Dir(params[10]) return path.Dir(params[10])
}
return "" return ""
} }
return "" return ""
}
func GetNodePid(key string) string {
str := getProcessInfo(key)
sstr := strings.Split(str,"\n")
regstr := util.DeleteExtraSpace(sstr[0])
params := strings.Split(regstr," ")
if len(params) == 11 {
if params[1] != "" {
return params[1]
}
return ""
} }
return "" return ""
} }
...@@ -360,7 +373,11 @@ func SafeCloseNode() (bool,error) { ...@@ -360,7 +373,11 @@ func SafeCloseNode() (bool,error) {
// return false,nil // return false,nil
//} //}
//return true,nil //return true,nil
close := exec.Command(GetAbsPath(setting.BityuanSetting.Name)+"/"+setting.BityuanSetting.Name+"-cli","close") path := GetAbsPath(setting.BityuanSetting.Name)
if path == "" {
return false,errors.New("node not running")
}
close := exec.Command(path+"/"+setting.BityuanSetting.Name+"-cli","close")
stderr := bytes.NewBuffer(nil) stderr := bytes.NewBuffer(nil)
close.Stderr = stderr close.Stderr = stderr
err := close.Start() err := close.Start()
......
...@@ -341,7 +341,8 @@ func Version(c* gin.Context){ ...@@ -341,7 +341,8 @@ func Version(c* gin.Context){
func NodeInfo(c *gin.Context){ func NodeInfo(c *gin.Context){
appG:=app.Gin{C:c} appG:=app.Gin{C:c}
if app.ServerStatus.NodeProcesssInfo.Pid == ""{ pid := app.GetNodePid(setting.BityuanSetting.Name)
if pid == ""{
appG.Response(http.StatusOK,e.NODE_ERROR,"node down") appG.Response(http.StatusOK,e.NODE_ERROR,"node down")
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment