Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chain33-pai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
szh
chain33-pai
Commits
58fee7f2
Commit
58fee7f2
authored
Jun 03, 2020
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update devstatus
parent
c3b61142
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
node.go
routers/api/v1/node.go
+3
-2
pai.go
routers/api/v1/pai.go
+1
-1
pai.go
service/pai_service/pai.go
+25
-0
No files found.
routers/api/v1/node.go
View file @
58fee7f2
...
...
@@ -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"
)
...
...
routers/api/v1/pai.go
View file @
58fee7f2
...
...
@@ -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
)
}
...
...
service/pai_service/pai.go
View file @
58fee7f2
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment