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
825852b0
Commit
825852b0
authored
Jun 02, 2020
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add err log
parent
c5c899b2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
+21
-11
raspberryChan.go
pkg/app/raspberryChan.go
+21
-11
No files found.
pkg/app/raspberryChan.go
View file @
825852b0
...
...
@@ -11,6 +11,9 @@ import (
"os"
)
var
(
path
string
)
func
RaspberryChan
()
{
for
{
...
...
@@ -19,6 +22,7 @@ func RaspberryChan() {
if
value
.
Name
==
""
{
continue
}
path
=
GetAbsPath
(
setting
.
BityuanSetting
.
Name
)
switch
value
.
Name
{
case
"ROLLBACK"
:
err
:=
rollback
()
...
...
@@ -84,7 +88,6 @@ func rollback() error {
time
.
Sleep
(
time
.
Second
*
2
)
tlog
.
Info
(
"rollback start"
,
"height"
,
pai
.
LocalLastHeight
,
"rollbackheight"
,
rollheight
)
var
buf
bytes
.
Buffer
path
:=
GetAbsPath
(
setting
.
BityuanSetting
.
Name
)
if
path
==
""
{
tlog
.
Error
(
"GetAbsPath"
,
"err"
,
"path not exists"
)
BityuanFlag
.
Flag
=
false
...
...
@@ -112,6 +115,7 @@ func backup() error {
ok
,
err
:=
SafeCloseNode
()
if
err
!=
nil
{
BityuanFlag
.
Flag
=
false
tlog
.
Error
(
"SafeCloseNode"
,
"err"
,
err
)
return
err
}
if
!
ok
{
...
...
@@ -123,20 +127,19 @@ func backup() error {
}
func
SafeBackup
()
error
{
backup
:=
exec
.
Command
(
"cp"
,
"-r"
,
"datadir"
,
"datadir_backup"
)
return
backup
.
Run
()
var
buf
bytes
.
Buffer
backup
:=
exec
.
Command
(
"cp"
,
"-r"
,
path
+
"/datadir"
,
path
+
"/datadir_backup"
)
backup
.
Stderr
=
&
buf
if
err
:=
backup
.
Run
();
err
!=
nil
{
tlog
.
Error
(
"SafeBackup"
,
"err"
,
buf
.
String
())
return
err
}
return
nil
}
func
recoverNode
()
error
{
BityuanFlag
.
Lock
.
Lock
()
defer
BityuanFlag
.
Lock
.
Unlock
()
remove
:=
exec
.
Command
(
"rm"
,
"-rf"
,
"datadir"
)
err
:=
remove
.
Run
()
if
err
!=
nil
{
tlog
.
Error
(
"rm -rf datadir"
,
"err"
,
err
)
return
err
}
path
:=
GetAbsPath
(
setting
.
BityuanSetting
.
Name
)
if
path
==
""
{
tlog
.
Error
(
"path empty"
,
"err"
,
"node not exists"
)
return
errors
.
New
(
"node not exists"
)
...
...
@@ -148,7 +151,14 @@ func recoverNode() error {
return
errors
.
New
(
"backup file not exists"
)
}
}
recover
:=
exec
.
Command
(
"cp"
,
"-r"
,
"datadir_backup"
,
"datadir"
)
remove
:=
exec
.
Command
(
"rm"
,
"-rf"
,
path
+
"/datadir"
)
err
:=
remove
.
Run
()
if
err
!=
nil
{
tlog
.
Error
(
"rm -rf datadir"
,
"err"
,
err
)
return
err
}
recover
:=
exec
.
Command
(
"cp"
,
"-r"
,
backupPath
,
path
+
"/datadir"
)
err
=
recover
.
Run
()
if
err
!=
nil
{
tlog
.
Error
(
"cp -r datadir_backup datadir"
,
"err"
,
err
)
...
...
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