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
9dde8ef6
Commit
9dde8ef6
authored
Dec 25, 2019
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新节点下载逻辑 删除配置参数downloaddir
parent
dc4772c3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
24 deletions
+41
-24
app.ini
conf/app.ini
+0
-1
process.go
pkg/app/process.go
+18
-0
setting.go
pkg/setting/setting.go
+0
-1
node.go
routers/api/v1/node.go
+21
-20
pai.go
routers/api/v1/pai.go
+2
-2
No files found.
conf/app.ini
View file @
9dde8ef6
...
@@ -55,5 +55,4 @@ Auto=/home/pi/chain33-pai/auto.sh
...
@@ -55,5 +55,4 @@ Auto=/home/pi/chain33-pai/auto.sh
Start
=
/home/pi/chain33-pai/star.sh
Start
=
/home/pi/chain33-pai/star.sh
StartUp
=
/home/pi/chain33-pai/startup.sh
StartUp
=
/home/pi/chain33-pai/startup.sh
DownloadUrl
=
https://bty33.oss-cn-shanghai.aliyuncs.com/raspberry/
DownloadUrl
=
https://bty33.oss-cn-shanghai.aliyuncs.com/raspberry/
DownloadDir
=
temp_pai
VersionUrl
=
http://112.124.4.47:8800/pai/latestversion
VersionUrl
=
http://112.124.4.47:8800/pai/latestversion
pkg/app/process.go
View file @
9dde8ef6
...
@@ -331,4 +331,21 @@ func DownLoadFile(url string,file string,ty int32) error {
...
@@ -331,4 +331,21 @@ func DownLoadFile(url string,file string,ty int32) error {
}
}
return
nil
return
nil
}
func
GetAbsPath
(
key
string
)
string
{
str
:=
getProcessInfo
(
key
)
sstr
:=
strings
.
Split
(
str
,
"
\n
"
)
regstr
:=
util
.
DeleteExtraSpace
(
sstr
[
0
])
params
:=
strings
.
Split
(
regstr
,
" "
)
if
len
(
params
)
==
11
{
if
params
[
10
]
!=
""
{
if
i
:=
strings
.
LastIndex
(
params
[
10
],
"/"
);
i
>=
0
{
return
params
[
10
][
0
:
i
+
1
]
}
return
""
}
return
""
}
return
""
}
}
\ No newline at end of file
pkg/setting/setting.go
View file @
9dde8ef6
...
@@ -79,7 +79,6 @@ type Chain33_pai struct {
...
@@ -79,7 +79,6 @@ type Chain33_pai struct {
Start
string
Start
string
StartUp
string
StartUp
string
DownloadUrl
string
DownloadUrl
string
DownloadDir
string
VersionUrl
string
VersionUrl
string
}
}
var
Chain33Pai
=&
Chain33_pai
{}
var
Chain33Pai
=&
Chain33_pai
{}
...
...
routers/api/v1/node.go
View file @
9dde8ef6
...
@@ -68,6 +68,7 @@ func UpdateNode(c *gin.Context){
...
@@ -68,6 +68,7 @@ func UpdateNode(c *gin.Context){
appG
.
Response
(
http
.
StatusOK
,
e
.
NODE_ERROR
,
"node internal error,could not start node"
)
appG
.
Response
(
http
.
StatusOK
,
e
.
NODE_ERROR
,
"node internal error,could not start node"
)
return
return
}
}
absPath
:=
app
.
GetAbsPath
(
setting
.
BityuanSetting
.
Name
)
app
.
BityuanFlag
=
true
app
.
BityuanFlag
=
true
app
.
UpdateInfo
.
Flag
=
false
app
.
UpdateInfo
.
Flag
=
false
setting
.
FreshVersion
()
setting
.
FreshVersion
()
...
@@ -121,7 +122,7 @@ func UpdateNode(c *gin.Context){
...
@@ -121,7 +122,7 @@ func UpdateNode(c *gin.Context){
return
return
}
}
//备份原文件 确保没有alias 关联
//备份原文件 确保没有alias 关联
bak
:=
exec
.
Command
(
"cp"
,
setting
.
BityuanSetting
.
Name
,
setting
.
BityuanSetting
.
Name
+
".bak"
)
bak
:=
exec
.
Command
(
"cp"
,
absPath
+
setting
.
BityuanSetting
.
Name
,
absPath
+
setting
.
BityuanSetting
.
Name
+
".bak"
)
err
=
bak
.
Start
()
err
=
bak
.
Start
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"bak"
,
err
)
log
.
Println
(
"bak"
,
err
)
...
@@ -139,7 +140,7 @@ func UpdateNode(c *gin.Context){
...
@@ -139,7 +140,7 @@ func UpdateNode(c *gin.Context){
return
return
}
}
//备份配置文件
//备份配置文件
bakconf
:=
exec
.
Command
(
"cp"
,
"bityuan.toml"
,
"bityuan.toml.bak"
)
bakconf
:=
exec
.
Command
(
"cp"
,
absPath
+
"bityuan.toml"
,
absPath
+
"bityuan.toml.bak"
)
err
=
bakconf
.
Start
()
err
=
bakconf
.
Start
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"bakconf"
,
err
)
log
.
Println
(
"bakconf"
,
err
)
...
@@ -157,7 +158,7 @@ func UpdateNode(c *gin.Context){
...
@@ -157,7 +158,7 @@ func UpdateNode(c *gin.Context){
return
return
}
}
//替换原执行文件
//替换原执行文件
mv
:=
exec
.
Command
(
"mv"
,
setting
.
BityuanSetting
.
Name
+
"_"
+
latestVersion
+
"/
"
+
setting
.
BityuanSetting
.
Name
,
"."
)
mv
:=
exec
.
Command
(
"mv"
,
setting
.
BityuanSetting
.
Name
+
"_"
+
latestVersion
+
"/
*"
,
absPath
)
err
=
mv
.
Start
()
err
=
mv
.
Start
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"mv"
,
err
)
log
.
Println
(
"mv"
,
err
)
...
@@ -174,23 +175,23 @@ func UpdateNode(c *gin.Context){
...
@@ -174,23 +175,23 @@ func UpdateNode(c *gin.Context){
app
.
BityuanFlag
=
false
app
.
BityuanFlag
=
false
return
return
}
}
mv2
:=
exec
.
Command
(
"mv"
,
setting
.
BityuanSetting
.
Name
+
"_"
+
latestVersion
+
"/"
+
"bityuan.toml"
,
"."
)
//
mv2 := exec.Command("mv",setting.BityuanSetting.Name+"_"+latestVersion+"/"+"bityuan.toml",".")
err
=
mv2
.
Start
()
//
err = mv2.Start()
if
err
!=
nil
{
//
if err != nil {
log
.
Println
(
"mv2"
,
err
)
//
log.Println("mv2",err)
appG
.
Response
(
http
.
StatusOK
,
e
.
MV_ERROR
,
err
)
//
appG.Response(http.StatusOK, e.MV_ERROR, err)
app
.
UpdateInfo
.
Flag
=
true
//
app.UpdateInfo.Flag = true
app
.
BityuanFlag
=
false
//
app.BityuanFlag = false
return
//
return
}
//
}
err
=
mv2
.
Wait
()
//
err = mv2.Wait()
if
err
!=
nil
{
//
if err != nil {
log
.
Println
(
"mv2"
,
err
)
//
log.Println("mv2",err)
appG
.
Response
(
http
.
StatusOK
,
e
.
MV_ERROR
,
err
)
//
appG.Response(http.StatusOK, e.MV_ERROR, err)
app
.
UpdateInfo
.
Flag
=
true
//
app.UpdateInfo.Flag = true
app
.
BityuanFlag
=
false
//
app.BityuanFlag = false
return
//
return
}
//
}
remove
:=
exec
.
Command
(
"rm"
,
"-rf"
,
setting
.
BityuanSetting
.
Name
+
"_"
+
latestVersion
,
name
)
remove
:=
exec
.
Command
(
"rm"
,
"-rf"
,
setting
.
BityuanSetting
.
Name
+
"_"
+
latestVersion
,
name
)
err
=
remove
.
Start
()
err
=
remove
.
Start
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
routers/api/v1/pai.go
View file @
9dde8ef6
...
@@ -126,7 +126,7 @@ func UpdatePai(c *gin.Context) {
...
@@ -126,7 +126,7 @@ func UpdatePai(c *gin.Context) {
return
return
}
}
//替换原执行文件
//替换原执行文件
mv
:=
exec
.
Command
(
"mv"
,
setting
.
Chain33Pai
.
DownloadDir
+
"/"
+
setting
.
Chain33Pai
.
Name
,
"."
)
mv
:=
exec
.
Command
(
"mv"
,
setting
.
Chain33Pai
.
Name
+
"_"
+
req
.
Version
+
"/"
+
setting
.
Chain33Pai
.
Name
,
"."
)
err
=
mv
.
Start
()
err
=
mv
.
Start
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"mv"
,
err
)
log
.
Println
(
"mv"
,
err
)
...
@@ -145,7 +145,7 @@ func UpdatePai(c *gin.Context) {
...
@@ -145,7 +145,7 @@ func UpdatePai(c *gin.Context) {
//删除temp文件夹
//删除temp文件夹
//替换原执行文件
//替换原执行文件
remove
:=
exec
.
Command
(
"rm"
,
"-rf"
,
setting
.
Chain33Pai
.
DownloadDir
,
name
)
remove
:=
exec
.
Command
(
"rm"
,
"-rf"
,
setting
.
Chain33Pai
.
Name
+
"_"
+
req
.
Version
,
name
)
err
=
remove
.
Start
()
err
=
remove
.
Start
()
if
err
!=
nil
{
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
RM_ERROR
,
err
)
appG
.
Response
(
http
.
StatusOK
,
e
.
RM_ERROR
,
err
)
...
...
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