Commit 841a6533 authored by szh's avatar szh

add close node

parent 29e375ab
...@@ -18,6 +18,7 @@ import ( ...@@ -18,6 +18,7 @@ import (
"io/ioutil" "io/ioutil"
"chain33-pai/pkg/util" "chain33-pai/pkg/util"
"chain33-pai/pkg/e" "chain33-pai/pkg/e"
"chain33-pai/pkg/chain33"
) )
type ProcessInfo struct { type ProcessInfo struct {
...@@ -349,3 +350,15 @@ func GetAbsPath(key string) string { ...@@ -349,3 +350,15 @@ func GetAbsPath(key string) string {
} }
return "" return ""
} }
func SafeCloseNode() (bool,error) {
var client chain33.PaiClient
reply,err := client.Close()
if err != nil {
return false,err
}
if !reply.IsOk {
return false,nil
}
return true,nil
}
\ No newline at end of file
...@@ -45,3 +45,7 @@ func (p *PaiClient) GetNetInfo() (*types.NodeNetInfo,error) { ...@@ -45,3 +45,7 @@ func (p *PaiClient) GetNetInfo() (*types.NodeNetInfo,error) {
func (p *PaiClient) Version()(*types.VersionInfo,error){ func (p *PaiClient) Version()(*types.VersionInfo,error){
return paiClient.Version(context.Background(),&types.ReqNil{}) return paiClient.Version(context.Background(),&types.ReqNil{})
} }
func (p *PaiClient) Close() (*types.Reply,error) {
return paiClient.CloseQueue(context.Background(),&types.ReqNil{})
}
\ No newline at end of file
...@@ -101,6 +101,13 @@ func UpdateNode(c *gin.Context){ ...@@ -101,6 +101,13 @@ func UpdateNode(c *gin.Context){
appG.Response(http.StatusOK,e.NETWORK_ERROR,"network error,please checkout your network then try again") appG.Response(http.StatusOK,e.NETWORK_ERROR,"network error,please checkout your network then try again")
return return
} }
t,err := app.SafeCloseNode()
if err != nil || !t {
app.UpdateInfo.Flag = true
app.BityuanFlag = false
appG.Response(http.StatusOK,e.NODE_ERROR,"close node error")
return
}
name := setting.BityuanSetting.Name+"_"+latestVersion+".tar.gz" name := setting.BityuanSetting.Name+"_"+latestVersion+".tar.gz"
url := setting.Chain33Pai.DownloadUrl+ name url := setting.Chain33Pai.DownloadUrl+ name
err = app.DownLoadFile(url,name,int32(1)) err = app.DownLoadFile(url,name,int32(1))
...@@ -257,7 +264,7 @@ func UpdateNode(c *gin.Context){ ...@@ -257,7 +264,7 @@ func UpdateNode(c *gin.Context){
appG.Response(http.StatusOK, e.NODE_ERROR,"start auto sh err") appG.Response(http.StatusOK, e.NODE_ERROR,"start auto sh err")
return return
} }
app.DPercent.Flag = false app.BityuanFlag = false
appG.Response(http.StatusOK,e.SUCCESS,"update job started") appG.Response(http.StatusOK,e.SUCCESS,"update job started")
} }
......
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