Commit 58fee7f2 authored by szh's avatar szh

update devstatus

parent c3b61142
...@@ -627,8 +627,9 @@ func NodeRecover(c *gin.Context) { ...@@ -627,8 +627,9 @@ func NodeRecover(c *gin.Context) {
p := pai.Disks[0].Use p := pai.Disks[0].Use
ps := strings.Split(p,"%") ps := strings.Split(p,"%")
pint,_ := strconv.Atoi(ps[0]) pint,_ := strconv.Atoi(ps[0])
if pint * 2 > 80 { if pint > 90 {
app.JobChan <- app.MsgType{Name:"DELETEBACKUP"} tlog.Error("disk ","err","disk space not enough")
//app.JobChan <- app.MsgType{Name:"DELETEBACKUP"}
} }
app.JobChan <- app.MsgType{Name:"RECOVER"} app.JobChan <- app.MsgType{Name:"RECOVER"}
appG.Response(http.StatusOK,e.SUCCESS,"bityuan ready to recover") appG.Response(http.StatusOK,e.SUCCESS,"bityuan ready to recover")
......
...@@ -31,7 +31,7 @@ func GetDevdetail(c *gin.Context) { ...@@ -31,7 +31,7 @@ func GetDevdetail(c *gin.Context) {
func GetDevstatus(c *gin.Context) { func GetDevstatus(c *gin.Context) {
appG := app.Gin{C: c} appG := app.Gin{C: c}
var pai pai_service.Pai var pai pai_service.Pai
err := pai.GetDevstatus() err := pai.SetPai()
if err != nil { if err != nil {
appG.Response(http.StatusOK, e.ERROR, nil) appG.Response(http.StatusOK, e.ERROR, nil)
} }
......
...@@ -14,6 +14,9 @@ import ( ...@@ -14,6 +14,9 @@ import (
"encoding/json" "encoding/json"
"chain33-pai/pkg/setting" "chain33-pai/pkg/setting"
"chain33-pai/pkg/pai" "chain33-pai/pkg/pai"
"chain33-pai/pkg/app"
"os"
"errors"
) )
var ( var (
...@@ -35,6 +38,7 @@ type Pai struct { ...@@ -35,6 +38,7 @@ type Pai struct {
Err string `json:"err"` Err string `json:"err"`
Arch string `json:"arch"` Arch string `json:"arch"`
Disks []*pai.Disk Disks []*pai.Disk
IsBackup bool `json:"is_backup"`
} }
type ReqUpdatePai struct { type ReqUpdatePai struct {
...@@ -48,6 +52,7 @@ func (p *Pai) SetPai() error { ...@@ -48,6 +52,7 @@ func (p *Pai) SetPai() error {
p.GetBtyVersion() p.GetBtyVersion()
p.SetPaiEnv() p.SetPaiEnv()
p.GetDiskUseage() p.GetDiskUseage()
p.CheckBackup()
return nil return nil
} }
...@@ -211,3 +216,22 @@ func (p *Pai) GetDiskUseage() error { ...@@ -211,3 +216,22 @@ func (p *Pai) GetDiskUseage() error {
} }
return nil 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