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
9a230a54
Commit
9a230a54
authored
Jun 02, 2020
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename path to btyPath
parent
825852b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
raspberryChan.go
pkg/app/raspberryChan.go
+15
-15
No files found.
pkg/app/raspberryChan.go
View file @
9a230a54
...
...
@@ -12,7 +12,7 @@ import (
)
var
(
p
ath
string
btyP
ath
string
)
func
RaspberryChan
()
{
...
...
@@ -22,7 +22,7 @@ func RaspberryChan() {
if
value
.
Name
==
""
{
continue
}
p
ath
=
GetAbsPath
(
setting
.
BityuanSetting
.
Name
)
btyP
ath
=
GetAbsPath
(
setting
.
BityuanSetting
.
Name
)
switch
value
.
Name
{
case
"ROLLBACK"
:
err
:=
rollback
()
...
...
@@ -88,12 +88,12 @@ func rollback() error {
time
.
Sleep
(
time
.
Second
*
2
)
tlog
.
Info
(
"rollback start"
,
"height"
,
pai
.
LocalLastHeight
,
"rollbackheight"
,
rollheight
)
var
buf
bytes
.
Buffer
if
p
ath
==
""
{
tlog
.
Error
(
"GetAbsPath"
,
"err"
,
"
p
ath not exists"
)
if
btyP
ath
==
""
{
tlog
.
Error
(
"GetAbsPath"
,
"err"
,
"
btyP
ath not exists"
)
BityuanFlag
.
Flag
=
false
return
err
}
cmd
:=
exec
.
Command
(
p
ath
+
"/"
+
setting
.
BityuanSetting
.
Name
,
"-rollback"
,
fmt
.
Sprintf
(
"%d"
,
rollheight
))
cmd
:=
exec
.
Command
(
btyP
ath
+
"/"
+
setting
.
BityuanSetting
.
Name
,
"-rollback"
,
fmt
.
Sprintf
(
"%d"
,
rollheight
))
cmd
.
Stdout
=
&
buf
err
=
cmd
.
Run
()
if
err
!=
nil
{
...
...
@@ -128,7 +128,7 @@ func backup() error {
func
SafeBackup
()
error
{
var
buf
bytes
.
Buffer
backup
:=
exec
.
Command
(
"cp"
,
"-r"
,
path
+
"/datadir"
,
p
ath
+
"/datadir_backup"
)
backup
:=
exec
.
Command
(
"cp"
,
"-r"
,
btyPath
+
"/datadir"
,
btyP
ath
+
"/datadir_backup"
)
backup
.
Stderr
=
&
buf
if
err
:=
backup
.
Run
();
err
!=
nil
{
tlog
.
Error
(
"SafeBackup"
,
"err"
,
buf
.
String
())
...
...
@@ -140,25 +140,25 @@ func SafeBackup() error {
func
recoverNode
()
error
{
BityuanFlag
.
Lock
.
Lock
()
defer
BityuanFlag
.
Lock
.
Unlock
()
if
p
ath
==
""
{
tlog
.
Error
(
"
p
ath empty"
,
"err"
,
"node not exists"
)
if
btyP
ath
==
""
{
tlog
.
Error
(
"
btyP
ath empty"
,
"err"
,
"node not exists"
)
return
errors
.
New
(
"node not exists"
)
}
backupPath
:=
p
ath
+
"/datadir_backup"
backupPath
:=
btyP
ath
+
"/datadir_backup"
if
_
,
err
:=
os
.
Stat
(
backupPath
);
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
tlog
.
Error
(
"backup file not exists"
,
"err"
,
backupPath
)
return
errors
.
New
(
"backup file not exists"
)
}
}
remove
:=
exec
.
Command
(
"rm"
,
"-rf"
,
p
ath
+
"/datadir"
)
remove
:=
exec
.
Command
(
"rm"
,
"-rf"
,
btyP
ath
+
"/datadir"
)
err
:=
remove
.
Run
()
if
err
!=
nil
{
tlog
.
Error
(
"rm -rf datadir"
,
"err"
,
err
)
return
err
}
recover
:=
exec
.
Command
(
"cp"
,
"-r"
,
backupPath
,
p
ath
+
"/datadir"
)
recover
:=
exec
.
Command
(
"cp"
,
"-r"
,
backupPath
,
btyP
ath
+
"/datadir"
)
err
=
recover
.
Run
()
if
err
!=
nil
{
tlog
.
Error
(
"cp -r datadir_backup datadir"
,
"err"
,
err
)
...
...
@@ -168,12 +168,12 @@ func recoverNode() error {
}
func
deleteBackup
()
error
{
p
ath
:=
GetAbsPath
(
setting
.
BityuanSetting
.
Name
)
if
p
ath
==
""
{
tlog
.
Error
(
"
p
ath empty"
,
"err"
,
"node not exists"
)
btyP
ath
:=
GetAbsPath
(
setting
.
BityuanSetting
.
Name
)
if
btyP
ath
==
""
{
tlog
.
Error
(
"
btyP
ath empty"
,
"err"
,
"node not exists"
)
return
errors
.
New
(
"node not exists"
)
}
backupPath
:=
p
ath
+
"/datadir_backup"
backupPath
:=
btyP
ath
+
"/datadir_backup"
if
_
,
err
:=
os
.
Stat
(
backupPath
);
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
tlog
.
Error
(
"backup file not exists"
,
"err"
,
backupPath
)
...
...
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