Commit 58fee7f2 authored by szh's avatar szh

update devstatus

parent c3b61142
......@@ -627,8 +627,9 @@ func NodeRecover(c *gin.Context) {
p := pai.Disks[0].Use
ps := strings.Split(p,"%")
pint,_ := strconv.Atoi(ps[0])
if pint * 2 > 80 {
app.JobChan <- app.MsgType{Name:"DELETEBACKUP"}
if pint > 90 {
tlog.Error("disk ","err","disk space not enough")
//app.JobChan <- app.MsgType{Name:"DELETEBACKUP"}
}
app.JobChan <- app.MsgType{Name:"RECOVER"}
appG.Response(http.StatusOK,e.SUCCESS,"bityuan ready to recover")
......
......@@ -31,7 +31,7 @@ func GetDevdetail(c *gin.Context) {
func GetDevstatus(c *gin.Context) {
appG := app.Gin{C: c}
var pai pai_service.Pai
err := pai.GetDevstatus()
err := pai.SetPai()
if err != nil {
appG.Response(http.StatusOK, e.ERROR, nil)
}
......
......@@ -14,6 +14,9 @@ import (
"encoding/json"
"chain33-pai/pkg/setting"
"chain33-pai/pkg/pai"
"chain33-pai/pkg/app"
"os"
"errors"
)
var (
......@@ -35,6 +38,7 @@ type Pai struct {
Err string `json:"err"`
Arch string `json:"arch"`
Disks []*pai.Disk
IsBackup bool `json:"is_backup"`
}
type ReqUpdatePai struct {
......@@ -48,6 +52,7 @@ func (p *Pai) SetPai() error {
p.GetBtyVersion()
p.SetPaiEnv()
p.GetDiskUseage()
p.CheckBackup()
return nil
}
......@@ -210,4 +215,23 @@ func (p *Pai) GetDiskUseage() error {
p.Disks = disks
}
return nil
}
func (p *Pai) CheckBackup() error {
path := app.GetAbsPath("v7-bityuan")
if path == "" {
tlog.Error("IsBackup","path","node not exists")
//p.IsBackup = false
return errors.New("node not exists")
}
backupPath := path + "/datadir_backup"
if _,err := os.Stat(backupPath);err != nil {
if os.IsNotExist(err) {
tlog.Error("backup file not exists","err",backupPath)
p.IsBackup = false
return errors.New("backup file not exists")
}
}
p.IsBackup = true
return nil
}
\ No newline at end of file
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