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
37629af9
Commit
37629af9
authored
Dec 29, 2020
by
YPJ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增Env字段和VersionTestUrl
parent
625c5df0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
26 deletions
+62
-26
app.ini
conf/app.ini
+3
-0
process.go
pkg/app/process.go
+2
-3
setting.go
pkg/setting/setting.go
+2
-0
node.go
routers/api/v1/node.go
+21
-22
pai.go
routers/api/v1/pai.go
+7
-1
pai.go
service/pai_service/pai.go
+27
-0
No files found.
conf/app.ini
View file @
37629af9
...
...
@@ -87,3 +87,5 @@ RaspberryServer=112.124.4.47
StopPai
=
/home/pi/chain33-pai/stop-pai.sh
UploadVersionUrl
=
https://raspserver.biqianbao.net/pai/uploadinfo
UploadTestUrl
=
https://raspserver.biqianbao.net/pai/uploadtest
VersionTestUrl
=
https://raspserver.biqianbao.net/pai/versiontest
Env
\ No newline at end of file
pkg/app/process.go
View file @
37629af9
...
...
@@ -3,6 +3,7 @@ package app
import
(
"bytes"
"chain33-pai/pkg/chain33"
"chain33-pai/pkg/file"
"chain33-pai/pkg/pai"
"chain33-pai/pkg/setting"
"chain33-pai/pkg/util"
...
...
@@ -23,7 +24,6 @@ import (
"strings"
"sync"
"time"
"chain33-pai/pkg/file"
)
var
tlog
=
log
.
New
(
"pkg"
,
"app"
)
...
...
@@ -141,7 +141,7 @@ func BityuanJob(ticker *time.Ticker) {
select
{
case
<-
ticker
.
C
:
BityuanFlag
.
Lock
.
Lock
()
if
!
BityuanFlag
.
Flag
&&
file
.
CheckNotExist
(
"/home/pi/chain33-pai/Lock.file"
){
//有更新,重置等节点重启操作时 禁止运行,防止冲突
if
!
BityuanFlag
.
Flag
&&
file
.
CheckNotExist
(
"/home/pi/chain33-pai/Lock.file"
)
{
//有更新,重置等节点重启操作时 禁止运行,防止冲突
//节点未启动 会调用auto启动
NodeError
=
getWalletInfo
()
//解锁钱包
...
...
@@ -540,7 +540,6 @@ func AutoUpdate() {
}
tlog
.
Info
(
"autoupdatepai"
,
"err"
,
GetVersion
())
DPercent
.
Flag
=
false
}
}
...
...
pkg/setting/setting.go
View file @
37629af9
...
...
@@ -93,6 +93,8 @@ type Chain33_pai struct {
StopPai
string
UploadVersionUrl
string
UploadTestUrl
string
VersionTestUrl
string
Env
string
}
var
Chain33Pai
=
&
Chain33_pai
{}
...
...
routers/api/v1/node.go
View file @
37629af9
...
...
@@ -6,6 +6,7 @@ import (
"chain33-pai/pkg/chain33"
"chain33-pai/pkg/e"
"chain33-pai/pkg/setting"
"chain33-pai/pkg/util"
"chain33-pai/service/pai_service"
"encoding/json"
"fmt"
...
...
@@ -19,10 +20,8 @@ import (
"reflect"
"strings"
"time"
"chain33-pai/pkg/util"
)
// @Summary 重置节点钱包
// @Description 重置节点钱包 无参
// @Accept json
...
...
@@ -31,8 +30,8 @@ import (
// @Router /pai/resetwallet [post]
func
ResetWallet
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESETWALLET"
,
JobID
:
app
.
JobID
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESETWALLET"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
...
...
@@ -170,8 +169,8 @@ func UpdateNodeNew(c *gin.Context) {
// @Router /pai/reset [post]
func
ResetNode
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESET"
,
JobID
:
app
.
JobID
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESET"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
...
...
@@ -232,8 +231,8 @@ func NodeInfo(c *gin.Context) {
// @Router /pai/restartnode [post]
func
RestartNode
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESTART"
,
JobID
:
app
.
JobID
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESTART"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
...
...
@@ -245,8 +244,8 @@ func RestartNode(c *gin.Context) {
// @Router /pai/closenode [post]
func
CloseNode
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"CLOSE"
,
JobID
:
app
.
JobID
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"CLOSE"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
...
...
@@ -527,15 +526,15 @@ func Test(c *gin.Context) {
func
Rollback
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"ROLLBACK"
,
JobID
:
app
.
JobID
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"ROLLBACK"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
func
NodeBackup
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"BACKUP"
,
JobID
:
app
.
JobID
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"BACKUP"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
//appG := app.Gin{C: c}
//var pai pai_service.Pai
...
...
@@ -580,8 +579,8 @@ func CheckBackup(c *gin.Context) {
func
NodeRecover
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RECOVER"
,
JobID
:
app
.
JobID
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RECOVER"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
//appG := app.Gin{C: c}
//var pai pai_service.Pai
...
...
@@ -610,8 +609,8 @@ func NodeRecover(c *gin.Context) {
func
DelBackup
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"DELETEBACKUP"
,
JobID
:
app
.
JobID
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"DELETEBACKUP"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
//appG := app.Gin{C: c}
//var pai pai_service.Pai
...
...
@@ -643,7 +642,7 @@ func JobStatus(c *gin.Context) {
tlog
.
Info
(
"invalid params"
)
return
}
if
_
,
exists
:=
app
.
JobDoneMap
[
req
.
JobID
];
exists
{
if
_
,
exists
:=
app
.
JobDoneMap
[
req
.
JobID
];
exists
{
if
app
.
JobDoneMap
[
req
.
JobID
]
!=
""
{
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
app
.
JobDoneMap
[
req
.
JobID
])
return
...
...
@@ -654,7 +653,7 @@ func JobStatus(c *gin.Context) {
appG
.
Response
(
http
.
StatusOK
,
e
.
JOB_NOT_DONE
,
nil
)
}
func
BityuanJob
(
c
*
gin
.
Context
)
{
func
BityuanJob
(
c
*
gin
.
Context
)
{
type
JReq
struct
{
JobMsg
string
`json:"job_msg" binding:"required"`
}
...
...
@@ -666,7 +665,7 @@ func BityuanJob (c *gin.Context) {
tlog
.
Info
(
"invalid params"
)
return
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
req
.
JobMsg
,
JobID
:
app
.
JobID
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
req
.
JobMsg
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
routers/api/v1/pai.go
View file @
37629af9
...
...
@@ -42,16 +42,22 @@ func GetDevstatus(c *gin.Context) {
func
GetPaiVersion
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
version
:=
app
.
GetVersion
()
var
pai
pai_service
.
Pai
var
pai
pai_service
.
Pai
latest
,
err
:=
pai
.
GetPaiLatestVersion
(
int32
(
2
))
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
nil
)
return
}
test
,
err
:=
pai
.
GetPaiVersionTest
(
int32
(
1
))
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
nil
)
return
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
gin
.
H
{
"current"
:
version
,
"latest"
:
latest
,
"test"
:
test
,
})
}
...
...
service/pai_service/pai.go
View file @
37629af9
...
...
@@ -225,6 +225,33 @@ func (p *Pai) GetPaiLatestVersion(t int32) (string, error) {
return
r
.
Data
,
nil
}
func
(
p
*
Pai
)
GetPaiVersionTest
(
t
int32
)
(
string
,
error
)
{
data
:=
make
(
map
[
string
]
interface
{})
data
[
"type"
]
=
t
bytesData
,
_
:=
json
.
Marshal
(
data
)
resp
,
err
:=
http
.
Post
(
setting
.
Chain33Pai
.
VersionTestUrl
,
"application/json"
,
bytes
.
NewReader
(
bytesData
))
if
err
!=
nil
{
return
""
,
err
}
defer
resp
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
return
""
,
err
}
type
res
struct
{
Code
int64
Msg
string
Data
string
}
var
r
res
err
=
json
.
Unmarshal
(
body
,
&
r
)
if
err
!=
nil
{
return
""
,
err
}
return
r
.
Data
,
nil
}
func
(
p
*
Pai
)
GetDiskUseage
()
error
{
disks
,
err
:=
pai
.
MonitorServer
()
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