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
0
Merge Requests
0
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
ligaishun
chain33-pai
Commits
544975cb
Commit
544975cb
authored
Dec 10, 2019
by
ligaishun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update node.go
parent
61acebbc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
20 deletions
+28
-20
node.go
routers/api/v1/node.go
+28
-20
No files found.
routers/api/v1/node.go
View file @
544975cb
...
...
@@ -22,14 +22,14 @@ func ResetWallet(c *gin.Context) {
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
app
.
NodeError
.
Error
())
return
}
cmd
:=
exec
.
Command
(
"kill"
,
"-9"
,
app
.
Wallet
.
Pid
)
cmd
:=
exec
.
Command
(
"kill"
,
"-9"
,
app
.
Bityuan
.
Pid
)
err
:=
cmd
.
Start
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
"fail to reset wallet"
)
log
.
Fatalln
(
err
)
return
}
err
=
os
.
RemoveAll
(
fmt
.
Sprintf
(
path
.
Dir
(
app
.
Wallet
.
Path
),
"/wallet"
))
err
=
os
.
RemoveAll
(
fmt
.
Sprintf
(
path
.
Dir
(
app
.
Bityuan
.
Path
),
"/wallet"
))
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
"fail to reset wallet"
)
log
.
Fatalln
(
err
)
...
...
@@ -51,20 +51,27 @@ func UpdateNode(c *gin.Context){
if
flag
{
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
"node is updating"
)
}
if
app
.
NodeError
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
app
.
NodeError
.
Error
())
return
}
setting
.
FreshVersion
()
app
.
UpdateInfo
.
Status
=
false
app
.
UpdateInfo
.
Info
=
"updating..."
latestVersion
:=
app
.
GetLatestVersion
()
app
.
UpdateInfo
.
Status
=
false
if
latestVersion
==
setting
.
BityuanSetting
.
Version
{
app
.
UpdateInfo
.
Info
=
"current version is latest"
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
"current version is latest"
)
return
}
if
flag
{
app
.
UpdateInfo
.
Info
=
"Updating..."
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
"node is updating"
)
return
}
if
latestVersion
==
""
{
flag
=
false
app
.
UpdateInfo
.
Info
=
"network error"
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
"network error"
)
return
}
...
...
@@ -77,18 +84,18 @@ func UpdateNode(c *gin.Context){
app
.
UpdateInfo
.
Info
=
err
.
Error
()
return
}
app
.
Copy
(
setting
.
BityuanSetting
.
Name
,
setting
.
BityuanSetting
.
Path
)
app
.
Copy
(
setting
.
BityuanSetting
.
Name
+
"-cli"
,
setting
.
BityuanSetting
.
Path
)
app
.
Copy
(
setting
.
BityuanSetting
.
Name
,
app
.
Bityuan
.
Path
)
app
.
Copy
(
fmt
.
Sprintf
(
setting
.
BityuanSetting
.
Name
,
"-cli"
),
app
.
Bityuan
.
Path
)
os
.
Chdir
(
".."
)
os
.
RemoveAll
(
"bityuan"
)
kill
:=
exec
.
Command
(
"kill"
,
"-9"
,
app
.
Wallet
.
Pid
)
os
.
RemoveAll
(
setting
.
BityuanSetting
.
Name
)
kill
:=
exec
.
Command
(
"kill"
,
"-9"
,
app
.
Bityuan
.
Pid
)
kill
.
Start
()
err
=
kill
.
Wait
()
if
err
!=
nil
{
flag
=
false
app
.
UpdateInfo
.
Info
=
"fail to update node "
return
}
if
err
!=
nil
{
flag
=
false
app
.
UpdateInfo
.
Info
=
"fail to update node "
return
}
err
=
app
.
StartProcess
(
setting
.
Chain33Pai
.
Auto
)
if
err
!=
nil
{
flag
=
false
...
...
@@ -118,14 +125,15 @@ func ResetNode(c* gin.Context){
app
.
UpdateInfo
.
Info
=
err
.
Error
()
return
}
app
.
Copy
(
setting
.
BityuanSetting
.
Name
,
path
.
Dir
(
setting
.
BityuanSetting
.
Path
))
app
.
Copy
(
setting
.
BityuanSetting
.
Name
,
path
.
Dir
(
setting
.
BityuanSetting
.
Path
))
//pro
app
.
Copy
(
setting
.
BityuanSetting
.
Name
+
"-cli"
,
path
.
Dir
(
setting
.
BityuanSetting
.
Path
))
os
.
Chdir
(
".."
)
os
.
RemoveAll
(
"bityuan"
)
os
.
Chdir
(
setting
.
BityuanSetting
.
Path
)
os
.
RemoveAll
(
"datadir"
)
os
.
Chdir
(
setting
.
Chain33Pai
.
Path
)
kill
:=
exec
.
Command
(
"kill"
,
"-9"
,
app
.
Wallet
.
Pid
)
os
.
Chdir
(
".."
)
//make操作进入了该目录
os
.
RemoveAll
(
setting
.
BityuanSetting
.
Name
)
//
os.Chdir(setting.BityuanSetting.Path)
os
.
RemoveAll
(
fmt
.
Sprint
(
app
.
Bityuan
.
Path
,
"/datadir"
)
)
//
os.Chdir(setting.Chain33Pai.Path)
kill
:=
exec
.
Command
(
"kill"
,
"-9"
,
app
.
Bityuan
.
Pid
)
//start := exec.Command(path.Dir(app.Wallet.Path) + "/" + app.Wallet.PName)
err
=
kill
.
Start
()
if
err
!=
nil
{
...
...
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