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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
33 deletions
+67
-33
app.ini
conf/app.ini
+4
-2
process.go
pkg/app/process.go
+4
-5
setting.go
pkg/setting/setting.go
+2
-0
node.go
routers/api/v1/node.go
+23
-25
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
...
@@ -86,4 +86,6 @@ IsCompleteNosshUrl=https://raspserver.biqianbao.net/pai/iscompletenew
...
@@ -86,4 +86,6 @@ IsCompleteNosshUrl=https://raspserver.biqianbao.net/pai/iscompletenew
RaspberryServer
=
112.124.4.47
RaspberryServer
=
112.124.4.47
StopPai
=
/home/pi/chain33-pai/stop-pai.sh
StopPai
=
/home/pi/chain33-pai/stop-pai.sh
UploadVersionUrl
=
https://raspserver.biqianbao.net/pai/uploadinfo
UploadVersionUrl
=
https://raspserver.biqianbao.net/pai/uploadinfo
UploadTestUrl
=
https://raspserver.biqianbao.net/pai/uploadtest
UploadTestUrl
=
https://raspserver.biqianbao.net/pai/uploadtest
\ No newline at end of file
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
...
@@ -3,6 +3,7 @@ package app
import
(
import
(
"bytes"
"bytes"
"chain33-pai/pkg/chain33"
"chain33-pai/pkg/chain33"
"chain33-pai/pkg/file"
"chain33-pai/pkg/pai"
"chain33-pai/pkg/pai"
"chain33-pai/pkg/setting"
"chain33-pai/pkg/setting"
"chain33-pai/pkg/util"
"chain33-pai/pkg/util"
...
@@ -23,7 +24,6 @@ import (
...
@@ -23,7 +24,6 @@ import (
"strings"
"strings"
"sync"
"sync"
"time"
"time"
"chain33-pai/pkg/file"
)
)
var
tlog
=
log
.
New
(
"pkg"
,
"app"
)
var
tlog
=
log
.
New
(
"pkg"
,
"app"
)
...
@@ -42,9 +42,9 @@ type updateInfo struct {
...
@@ -42,9 +42,9 @@ type updateInfo struct {
}
}
type
Server
struct
{
type
Server
struct
{
Disks
[]
*
pai
.
Disk
`json:"disks"`
//硬盘信息
Disks
[]
*
pai
.
Disk
`json:"disks"`
//硬盘信息
NodeProcessInfo
ProcessInfo
`json:"node_process_info"`
//节点信息
NodeProcessInfo
ProcessInfo
`json:"node_process_info"`
//节点信息
Error
string
`json:"error"`
//错误信息
Error
string
`json:"error"`
//错误信息
}
}
type
BTYDownloadInfo
struct
{
type
BTYDownloadInfo
struct
{
...
@@ -141,7 +141,7 @@ func BityuanJob(ticker *time.Ticker) {
...
@@ -141,7 +141,7 @@ func BityuanJob(ticker *time.Ticker) {
select
{
select
{
case
<-
ticker
.
C
:
case
<-
ticker
.
C
:
BityuanFlag
.
Lock
.
Lock
()
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启动
//节点未启动 会调用auto启动
NodeError
=
getWalletInfo
()
NodeError
=
getWalletInfo
()
//解锁钱包
//解锁钱包
...
@@ -540,7 +540,6 @@ func AutoUpdate() {
...
@@ -540,7 +540,6 @@ func AutoUpdate() {
}
}
tlog
.
Info
(
"autoupdatepai"
,
"err"
,
GetVersion
())
tlog
.
Info
(
"autoupdatepai"
,
"err"
,
GetVersion
())
DPercent
.
Flag
=
false
DPercent
.
Flag
=
false
}
}
}
}
...
...
pkg/setting/setting.go
View file @
37629af9
...
@@ -93,6 +93,8 @@ type Chain33_pai struct {
...
@@ -93,6 +93,8 @@ type Chain33_pai struct {
StopPai
string
StopPai
string
UploadVersionUrl
string
UploadVersionUrl
string
UploadTestUrl
string
UploadTestUrl
string
VersionTestUrl
string
Env
string
}
}
var
Chain33Pai
=
&
Chain33_pai
{}
var
Chain33Pai
=
&
Chain33_pai
{}
...
...
routers/api/v1/node.go
View file @
37629af9
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"chain33-pai/pkg/chain33"
"chain33-pai/pkg/chain33"
"chain33-pai/pkg/e"
"chain33-pai/pkg/e"
"chain33-pai/pkg/setting"
"chain33-pai/pkg/setting"
"chain33-pai/pkg/util"
"chain33-pai/service/pai_service"
"chain33-pai/service/pai_service"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
...
@@ -19,10 +20,8 @@ import (
...
@@ -19,10 +20,8 @@ import (
"reflect"
"reflect"
"strings"
"strings"
"time"
"time"
"chain33-pai/pkg/util"
)
)
// @Summary 重置节点钱包
// @Summary 重置节点钱包
// @Description 重置节点钱包 无参
// @Description 重置节点钱包 无参
// @Accept json
// @Accept json
...
@@ -31,8 +30,8 @@ import (
...
@@ -31,8 +30,8 @@ import (
// @Router /pai/resetwallet [post]
// @Router /pai/resetwallet [post]
func
ResetWallet
(
c
*
gin
.
Context
)
{
func
ResetWallet
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESETWALLET"
,
JobID
:
app
.
JobID
}
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESETWALLET"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
}
...
@@ -170,8 +169,8 @@ func UpdateNodeNew(c *gin.Context) {
...
@@ -170,8 +169,8 @@ func UpdateNodeNew(c *gin.Context) {
// @Router /pai/reset [post]
// @Router /pai/reset [post]
func
ResetNode
(
c
*
gin
.
Context
)
{
func
ResetNode
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESET"
,
JobID
:
app
.
JobID
}
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESET"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
}
...
@@ -194,7 +193,7 @@ func Version(c *gin.Context) {
...
@@ -194,7 +193,7 @@ func Version(c *gin.Context) {
setting
.
FreshVersion
()
setting
.
FreshVersion
()
//latestVersion:=app.GetLatestVersion()
//latestVersion:=app.GetLatestVersion()
var
pai
pai_service
.
Pai
var
pai
pai_service
.
Pai
//1 bityuan
2
chain33-pai
//1 bityuan
2
chain33-pai
latestVersion
,
err
:=
pai
.
GetPaiLatestVersion
(
int32
(
1
))
latestVersion
,
err
:=
pai
.
GetPaiLatestVersion
(
int32
(
1
))
if
latestVersion
==
""
||
err
!=
nil
{
if
latestVersion
==
""
||
err
!=
nil
{
...
@@ -232,8 +231,8 @@ func NodeInfo(c *gin.Context) {
...
@@ -232,8 +231,8 @@ func NodeInfo(c *gin.Context) {
// @Router /pai/restartnode [post]
// @Router /pai/restartnode [post]
func
RestartNode
(
c
*
gin
.
Context
)
{
func
RestartNode
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESTART"
,
JobID
:
app
.
JobID
}
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RESTART"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
}
...
@@ -245,8 +244,8 @@ func RestartNode(c *gin.Context) {
...
@@ -245,8 +244,8 @@ func RestartNode(c *gin.Context) {
// @Router /pai/closenode [post]
// @Router /pai/closenode [post]
func
CloseNode
(
c
*
gin
.
Context
)
{
func
CloseNode
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"CLOSE"
,
JobID
:
app
.
JobID
}
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"CLOSE"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
}
...
@@ -527,15 +526,15 @@ func Test(c *gin.Context) {
...
@@ -527,15 +526,15 @@ func Test(c *gin.Context) {
func
Rollback
(
c
*
gin
.
Context
)
{
func
Rollback
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"ROLLBACK"
,
JobID
:
app
.
JobID
}
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"ROLLBACK"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
}
func
NodeBackup
(
c
*
gin
.
Context
)
{
func
NodeBackup
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"BACKUP"
,
JobID
:
app
.
JobID
}
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"BACKUP"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
//appG := app.Gin{C: c}
//appG := app.Gin{C: c}
//var pai pai_service.Pai
//var pai pai_service.Pai
...
@@ -580,8 +579,8 @@ func CheckBackup(c *gin.Context) {
...
@@ -580,8 +579,8 @@ func CheckBackup(c *gin.Context) {
func
NodeRecover
(
c
*
gin
.
Context
)
{
func
NodeRecover
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RECOVER"
,
JobID
:
app
.
JobID
}
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"RECOVER"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
//appG := app.Gin{C: c}
//appG := app.Gin{C: c}
//var pai pai_service.Pai
//var pai pai_service.Pai
...
@@ -610,8 +609,8 @@ func NodeRecover(c *gin.Context) {
...
@@ -610,8 +609,8 @@ func NodeRecover(c *gin.Context) {
func
DelBackup
(
c
*
gin
.
Context
)
{
func
DelBackup
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
appG
:=
app
.
Gin
{
C
:
c
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"DELETEBACKUP"
,
JobID
:
app
.
JobID
}
app
.
JobChan
<-
app
.
MsgType
{
Name
:
"DELETEBACKUP"
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
//appG := app.Gin{C: c}
//appG := app.Gin{C: c}
//var pai pai_service.Pai
//var pai pai_service.Pai
...
@@ -643,7 +642,7 @@ func JobStatus(c *gin.Context) {
...
@@ -643,7 +642,7 @@ func JobStatus(c *gin.Context) {
tlog
.
Info
(
"invalid params"
)
tlog
.
Info
(
"invalid params"
)
return
return
}
}
if
_
,
exists
:=
app
.
JobDoneMap
[
req
.
JobID
];
exists
{
if
_
,
exists
:=
app
.
JobDoneMap
[
req
.
JobID
];
exists
{
if
app
.
JobDoneMap
[
req
.
JobID
]
!=
""
{
if
app
.
JobDoneMap
[
req
.
JobID
]
!=
""
{
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
app
.
JobDoneMap
[
req
.
JobID
])
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
app
.
JobDoneMap
[
req
.
JobID
])
return
return
...
@@ -654,7 +653,7 @@ func JobStatus(c *gin.Context) {
...
@@ -654,7 +653,7 @@ func JobStatus(c *gin.Context) {
appG
.
Response
(
http
.
StatusOK
,
e
.
JOB_NOT_DONE
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
JOB_NOT_DONE
,
nil
)
}
}
func
BityuanJob
(
c
*
gin
.
Context
)
{
func
BityuanJob
(
c
*
gin
.
Context
)
{
type
JReq
struct
{
type
JReq
struct
{
JobMsg
string
`json:"job_msg" binding:"required"`
JobMsg
string
`json:"job_msg" binding:"required"`
}
}
...
@@ -666,7 +665,7 @@ func BityuanJob (c *gin.Context) {
...
@@ -666,7 +665,7 @@ func BityuanJob (c *gin.Context) {
tlog
.
Info
(
"invalid params"
)
tlog
.
Info
(
"invalid params"
)
return
return
}
}
util
.
AddValue
(
&
app
.
JobID
,
1
)
util
.
AddValue
(
&
app
.
JobID
,
1
)
app
.
JobChan
<-
app
.
MsgType
{
Name
:
req
.
JobMsg
,
JobID
:
app
.
JobID
}
app
.
JobChan
<-
app
.
MsgType
{
Name
:
req
.
JobMsg
,
JobID
:
app
.
JobID
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
app
.
JobID
)
}
}
\ No newline at end of file
routers/api/v1/pai.go
View file @
37629af9
...
@@ -42,16 +42,22 @@ func GetDevstatus(c *gin.Context) {
...
@@ -42,16 +42,22 @@ func GetDevstatus(c *gin.Context) {
func
GetPaiVersion
(
c
*
gin
.
Context
)
{
func
GetPaiVersion
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
appG
:=
app
.
Gin
{
C
:
c
}
version
:=
app
.
GetVersion
()
version
:=
app
.
GetVersion
()
var
pai
pai_service
.
Pai
var
pai
pai_service
.
Pai
latest
,
err
:=
pai
.
GetPaiLatestVersion
(
int32
(
2
))
latest
,
err
:=
pai
.
GetPaiLatestVersion
(
int32
(
2
))
if
err
!=
nil
{
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
nil
)
return
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
{
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
gin
.
H
{
"current"
:
version
,
"current"
:
version
,
"latest"
:
latest
,
"latest"
:
latest
,
"test"
:
test
,
})
})
}
}
...
...
service/pai_service/pai.go
View file @
37629af9
...
@@ -225,6 +225,33 @@ func (p *Pai) GetPaiLatestVersion(t int32) (string, error) {
...
@@ -225,6 +225,33 @@ func (p *Pai) GetPaiLatestVersion(t int32) (string, error) {
return
r
.
Data
,
nil
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
{
func
(
p
*
Pai
)
GetDiskUseage
()
error
{
disks
,
err
:=
pai
.
MonitorServer
()
disks
,
err
:=
pai
.
MonitorServer
()
if
err
!=
nil
{
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