Commit 544975cb authored by ligaishun's avatar ligaishun

Update node.go

parent 61acebbc
......@@ -22,14 +22,14 @@ func ResetWallet(c *gin.Context) {
appG.Response(http.StatusOK, e.ERROR, app.NodeError.Error())
return
}
cmd:=exec.Command("kill","-9",app.Wallet.Pid)
cmd:=exec.Command("kill","-9",app.Bityuan.Pid)
err:=cmd.Start()
if err!=nil{
appG.Response(http.StatusOK, e.ERROR, "fail to reset wallet")
log.Fatalln(err)
return
}
err=os.RemoveAll(fmt.Sprintf(path.Dir(app.Wallet.Path),"/wallet"))
err=os.RemoveAll(fmt.Sprintf(path.Dir(app.Bityuan.Path),"/wallet"))
if err!=nil{
appG.Response(http.StatusOK, e.ERROR, "fail to reset wallet")
log.Fatalln(err)
......@@ -51,20 +51,27 @@ func UpdateNode(c *gin.Context){
if flag{
appG.Response(http.StatusOK,e.SUCCESS,"node is updating")
}
if app.NodeError!=nil{
appG.Response(http.StatusOK, e.ERROR, app.NodeError.Error())
return
}
setting.FreshVersion()
app.UpdateInfo.Status=false
app.UpdateInfo.Info="updating..."
latestVersion:=app.GetLatestVersion()
app.UpdateInfo.Status=false
if latestVersion==setting.BityuanSetting.Version{
app.UpdateInfo.Info="current version is latest"
appG.Response(http.StatusOK,e.SUCCESS,"current version is latest")
return
}
if flag{
app.UpdateInfo.Info="Updating..."
appG.Response(http.StatusOK,e.SUCCESS,"node is updating")
return
}
if latestVersion==""{
flag=false
app.UpdateInfo.Info="network error"
appG.Response(http.StatusOK,e.ERROR,"network error")
return
}
......@@ -77,18 +84,18 @@ func UpdateNode(c *gin.Context){
app.UpdateInfo.Info=err.Error()
return
}
app.Copy(setting.BityuanSetting.Name,setting.BityuanSetting.Path)
app.Copy(setting.BityuanSetting.Name+"-cli",setting.BityuanSetting.Path)
app.Copy(setting.BityuanSetting.Name,app.Bityuan.Path)
app.Copy(fmt.Sprintf(setting.BityuanSetting.Name,"-cli"),app.Bityuan.Path)
os.Chdir("..")
os.RemoveAll("bityuan")
kill:=exec.Command("kill","-9",app.Wallet.Pid)
os.RemoveAll(setting.BityuanSetting.Name)
kill:=exec.Command("kill","-9",app.Bityuan.Pid)
kill.Start()
err=kill.Wait()
if err!=nil{
flag=false
app.UpdateInfo.Info="fail to update node "
return
}
if err!=nil{
flag=false
app.UpdateInfo.Info="fail to update node "
return
}
err=app.StartProcess(setting.Chain33Pai.Auto)
if err!=nil{
flag=false
......@@ -118,14 +125,15 @@ func ResetNode(c* gin.Context){
app.UpdateInfo.Info = err.Error()
return
}
app.Copy(setting.BityuanSetting.Name, path.Dir(setting.BityuanSetting.Path))
app.Copy(setting.BityuanSetting.Name, path.Dir(setting.BityuanSetting.Path))//pro
app.Copy(setting.BityuanSetting.Name+"-cli", path.Dir(setting.BityuanSetting.Path))
os.Chdir("..")
os.RemoveAll("bityuan")
os.Chdir(setting.BityuanSetting.Path)
os.RemoveAll("datadir")
os.Chdir(setting.Chain33Pai.Path)
kill := exec.Command("kill", "-9", app.Wallet.Pid)
os.Chdir("..")//make操作进入了该目录
os.RemoveAll(setting.BityuanSetting.Name)
//os.Chdir(setting.BityuanSetting.Path)
os.RemoveAll(fmt.Sprint(app.Bityuan.Path,"/datadir"))
//os.Chdir(setting.Chain33Pai.Path)
kill := exec.Command("kill", "-9", app.Bityuan.Pid)
//start := exec.Command(path.Dir(app.Wallet.Path) + "/" + app.Wallet.PName)
err=kill.Start()
if err != nil {
......
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