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
841a6533
Commit
841a6533
authored
Dec 26, 2019
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add close node
parent
29e375ab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
process.go
pkg/app/process.go
+14
-0
client.go
pkg/chain33/client.go
+5
-0
node.go
routers/api/v1/node.go
+8
-1
No files found.
pkg/app/process.go
View file @
841a6533
...
...
@@ -18,6 +18,7 @@ import (
"io/ioutil"
"chain33-pai/pkg/util"
"chain33-pai/pkg/e"
"chain33-pai/pkg/chain33"
)
type
ProcessInfo
struct
{
...
...
@@ -348,4 +349,16 @@ func GetAbsPath(key string) string {
return
""
}
return
""
}
func
SafeCloseNode
()
(
bool
,
error
)
{
var
client
chain33
.
PaiClient
reply
,
err
:=
client
.
Close
()
if
err
!=
nil
{
return
false
,
err
}
if
!
reply
.
IsOk
{
return
false
,
nil
}
return
true
,
nil
}
\ No newline at end of file
pkg/chain33/client.go
View file @
841a6533
...
...
@@ -44,4 +44,8 @@ func (p *PaiClient) GetNetInfo() (*types.NodeNetInfo,error) {
func
(
p
*
PaiClient
)
Version
()(
*
types
.
VersionInfo
,
error
){
return
paiClient
.
Version
(
context
.
Background
(),
&
types
.
ReqNil
{})
}
func
(
p
*
PaiClient
)
Close
()
(
*
types
.
Reply
,
error
)
{
return
paiClient
.
CloseQueue
(
context
.
Background
(),
&
types
.
ReqNil
{})
}
\ No newline at end of file
routers/api/v1/node.go
View file @
841a6533
...
...
@@ -101,6 +101,13 @@ func UpdateNode(c *gin.Context){
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
"network error,please checkout your network then try again"
)
return
}
t
,
err
:=
app
.
SafeCloseNode
()
if
err
!=
nil
||
!
t
{
app
.
UpdateInfo
.
Flag
=
true
app
.
BityuanFlag
=
false
appG
.
Response
(
http
.
StatusOK
,
e
.
NODE_ERROR
,
"close node error"
)
return
}
name
:=
setting
.
BityuanSetting
.
Name
+
"_"
+
latestVersion
+
".tar.gz"
url
:=
setting
.
Chain33Pai
.
DownloadUrl
+
name
err
=
app
.
DownLoadFile
(
url
,
name
,
int32
(
1
))
...
...
@@ -257,7 +264,7 @@ func UpdateNode(c *gin.Context){
appG
.
Response
(
http
.
StatusOK
,
e
.
NODE_ERROR
,
"start auto sh err"
)
return
}
app
.
DPercent
.
Flag
=
false
app
.
Bityuan
Flag
=
false
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
"update job started"
)
}
...
...
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