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
bebe8928
Commit
bebe8928
authored
Dec 18, 2019
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pai版本更新
parent
89a47843
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
6 deletions
+53
-6
README.md
README.md
+5
-2
app.ini
conf/app.ini
+2
-1
msg.go
pkg/e/msg.go
+3
-0
setting.go
pkg/setting/setting.go
+1
-0
pai.go
routers/api/v1/pai.go
+11
-1
pai.go
service/pai_service/pai.go
+31
-2
No files found.
README.md
View file @
bebe8928
...
...
@@ -189,7 +189,10 @@ response
{
"code": 200,
"msg": "ok",
"data": "0.1.0"
"data": {
"current": "6.3.2",
"latest":: "6.3.2"
}
}
```
...
...
@@ -202,7 +205,7 @@ URL /pai/updatepai
|参数|类型|是否必填|说明|
|-|-|-|-|
|version|string|是|版本号|
```
response
{
...
...
conf/app.ini
View file @
bebe8928
...
...
@@ -54,5 +54,6 @@ Path=/home/pi/chain33-pai/
Auto
=
/home/pi/chain33-pai/auto.sh
Start
=
/home/pi/chain33-pai/star.sh
StartUp
=
/home/pi/chain33-pai/startup.sh
DownloadUrl
=
https://bty33.oss-cn-shanghai.aliyuncs.com/
DownloadUrl
=
https://bty33.oss-cn-shanghai.aliyuncs.com/
raspberry/
DownloadDir
=
temp-pai
VersionUrl
=
http://112.124.4.47:8800/pai/latestversion
pkg/e/msg.go
View file @
bebe8928
...
...
@@ -4,6 +4,9 @@ var MsgFlags = map[int]string{
SUCCESS
:
"ok"
,
ERROR
:
"fail"
,
INVALID_PARAMS
:
"请求参数错误"
,
DOWNLOAD_ERROR
:
"下载出错"
,
TAR_XVF_ERROR
:
"解压文件出错"
,
CP_ERROR
:
"拷贝文件出错"
,
ERROR_EXIST_TAG
:
"已存在该标签名称"
,
ERROR_EXIST_TAG_FAIL
:
"获取已存在标签失败"
,
ERROR_NOT_EXIST_TAG
:
"该标签不存在"
,
...
...
pkg/setting/setting.go
View file @
bebe8928
...
...
@@ -80,6 +80,7 @@ type Chain33_pai struct {
StartUp
string
DownloadUrl
string
DownloadDir
string
VersionUrl
string
}
var
Chain33Pai
=&
Chain33_pai
{}
...
...
routers/api/v1/pai.go
View file @
bebe8928
...
...
@@ -36,7 +36,17 @@ func GetDevstatus(c *gin.Context) {
func
GetPaiVersion
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
version
:=
app
.
GetVersion
()
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
version
)
var
pai
pai_service
.
Pai
latest
,
err
:=
pai
.
GetPaiLatestVersion
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
nil
)
return
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
gin
.
H
{
"current"
:
version
,
"latest"
:
latest
,
})
}
//只下载程序 重启生效
...
...
service/pai_service/pai.go
View file @
bebe8928
...
...
@@ -9,6 +9,11 @@ import (
"chain33-pai/pkg/chain33"
"chain33-pai/pkg/logging"
"github.com/33cn/chain33/types"
"net/http"
"bytes"
"io/ioutil"
"encoding/json"
"chain33-pai/pkg/setting"
)
var
(
...
...
@@ -129,4 +134,29 @@ func getPaiConfig(command string ,arg ...string) (config map[string]string,err e
}
return
list
,
nil
}
\ No newline at end of file
}
func
(
p
*
Pai
)
GetPaiLatestVersion
()
(
string
,
error
)
{
data
:=
make
(
map
[
string
]
interface
{})
data
[
"type"
]
=
2
bytesData
,
_
:=
json
.
Marshal
(
data
)
resp
,
err
:=
http
.
Post
(
setting
.
Chain33Pai
.
VersionUrl
,
"application/json"
,
bytes
.
NewReader
(
bytesData
))
if
err
!=
nil
{
return
""
,
err
}
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
}
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