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
12e1676f
Commit
12e1676f
authored
Dec 18, 2019
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
7e1b435e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
11 deletions
+13
-11
code.go
pkg/e/code.go
+1
-0
msg.go
pkg/e/msg.go
+1
-0
pai.go
routers/api/v1/pai.go
+11
-11
No files found.
pkg/e/code.go
View file @
12e1676f
...
...
@@ -13,6 +13,7 @@ const (
TAR_XVF_ERROR
=
5006
CP_ERROR
=
5007
RM_ERROR
=
5008
MV_ERROR
=
5009
ERROR_EXIST_TAG
=
10001
ERROR_EXIST_TAG_FAIL
=
10002
ERROR_NOT_EXIST_TAG
=
10003
...
...
pkg/e/msg.go
View file @
12e1676f
...
...
@@ -8,6 +8,7 @@ var MsgFlags = map[int]string{
TAR_XVF_ERROR
:
"解压文件出错"
,
CP_ERROR
:
"拷贝文件出错"
,
RM_ERROR
:
"删除文件出错"
,
MV_ERROR
:
"移动文件出错"
,
ERROR_EXIST_TAG
:
"已存在该标签名称"
,
ERROR_EXIST_TAG_FAIL
:
"获取已存在标签失败"
,
ERROR_NOT_EXIST_TAG
:
"该标签不存在"
,
...
...
routers/api/v1/pai.go
View file @
12e1676f
...
...
@@ -64,55 +64,55 @@ func UpdatePai(c *gin.Context) {
//oss下载更新包
err
=
app
.
DownLoadFile
(
url
,
name
)
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
DOWNLOAD_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
DOWNLOAD_ERROR
,
err
)
return
}
//解压缩文件
tar
:=
exec
.
Command
(
"tar"
,
"-xvf"
,
name
)
err
=
tar
.
Start
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
TAR_XVF_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
TAR_XVF_ERROR
,
err
)
return
}
err
=
tar
.
Wait
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
TAR_XVF_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
TAR_XVF_ERROR
,
err
)
return
}
//备份原文件 确保没有alias 关联
bak
:=
exec
.
Command
(
"cp"
,
setting
.
Chain33Pai
.
Name
,
setting
.
Chain33Pai
.
Name
+
".bak"
)
err
=
bak
.
Start
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
CP_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
CP_ERROR
,
err
)
return
}
err
=
bak
.
Wait
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
CP_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
CP_ERROR
,
err
)
return
}
//备份配置文件
bakconf
:=
exec
.
Command
(
"cp"
,
"conf/app.ini"
,
"conf/app.ini.bak"
)
err
=
bakconf
.
Start
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
CP_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
CP_ERROR
,
err
)
return
}
err
=
bakconf
.
Wait
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
CP_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
CP_ERROR
,
err
)
return
}
//替换原执行文件
replace
:=
exec
.
Command
(
"mv"
,
setting
.
Chain33Pai
.
DownloadDir
+
"/"
+
setting
.
Chain33Pai
.
Name
,
setting
.
Chain33Pai
.
Name
)
err
=
replace
.
Start
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
CP_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
MV_ERROR
,
err
)
return
}
err
=
replace
.
Wait
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
CP_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
MV_ERROR
,
err
)
return
}
//对比配置文件 比较麻烦
...
...
@@ -122,12 +122,12 @@ func UpdatePai(c *gin.Context) {
remove
:=
exec
.
Command
(
"rm"
,
"-rf"
,
setting
.
Chain33Pai
.
DownloadDir
,
name
)
err
=
remove
.
Start
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
RM_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
RM_ERROR
,
err
)
return
}
err
=
remove
.
Wait
()
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
RM_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
RM_ERROR
,
err
)
return
}
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
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