Commit b6545200 authored by szh's avatar szh

add rollback interface

parent 4d0d5402
......@@ -569,19 +569,26 @@ func Rollback(c *gin.Context) {
app.BityuanFlag = false
return
}
rollheight := pai.LocalLastHeight
if pai.LocalLastHeight == 0 {
tlog.Error("LocalLastHeight","height",pai.LocalLastHeight)
appG.Response(http.StatusOK,e.NODE_ERROR,err)
app.BityuanFlag = false
return
}
rollheight := pai.LocalLastHeight - 1000
if (pai.LocalLastHeight - 1000) <= 0 {
rollheight = 1
}
time.Sleep(time.Second * 2)
tlog.Info("rollback start","height",pai.LocalLastHeight,"rollbackheight",rollheight)
var buf bytes.Buffer
cmd := exec.Command("v7-bityuan", "-rollback",fmt.Sprintf("%d",rollheight))
path := app.GetAbsPath(setting.BityuanSetting.Name)
if path == "" {
tlog.Error("GetAbsPath","err","path not exists")
appG.Response(http.StatusOK,e.NODE_ERROR,err)
return
}
cmd := exec.Command(path+"/"+setting.BityuanSetting.Name, "-rollback",fmt.Sprintf("%d",rollheight))
cmd.Stdout = &buf
err = cmd.Run()
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