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
4dbab315
Commit
4dbab315
authored
Mar 31, 2020
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 bityuan6.3.0升级到6.4.0代码
parent
54537889
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
3 deletions
+41
-3
main.go
main.go
+1
-1
process.go
pkg/app/process.go
+40
-2
No files found.
main.go
View file @
4dbab315
...
...
@@ -44,7 +44,7 @@ func main() {
//go app.ClearLog(time.NewTicker(time.Hour*1))
//上传统计树莓派信息
go
app
.
UploadInfo
(
time
.
NewTicker
(
time
.
Minute
*
1
))
go
app
.
UploadInfo
(
time
.
NewTicker
(
time
.
Hour
*
1
))
routersInit
:=
routers
.
InitRouter
()
readTimeout
:=
setting
.
ServerSetting
.
ReadTimeout
...
...
pkg/app/process.go
View file @
4dbab315
...
...
@@ -21,6 +21,7 @@ import (
"github.com/33cn/chain33/types"
"chain33-pai/service/pai_service"
"encoding/json"
"chain33-pai/pkg/chain33"
)
var
tlog
=
log
.
New
(
"pkg"
,
"app"
)
...
...
@@ -609,6 +610,8 @@ func uploadVersion() error {
//update bityuan 6.3.x to 6.4.0
func
updateBityuan640
()
error
{
BityuanFlag
=
true
plantime
:=
int64
(
1585656000
)
nowtime
:=
time
.
Now
()
.
Unix
()
...
...
@@ -617,13 +620,31 @@ func updateBityuan640() error {
BityuanFlag
=
false
return
errors
.
New
(
"waiting plantime to update"
)
}
update
:=
GetNodeUpdateStatus
()
if
update
{
tlog
.
Info
(
"updateBityuan640 is updating"
,
"update"
,
update
)
return
nil
}
var
pai
chain33
.
PaiClient
v
,
err
:=
pai
.
Version
()
if
err
!=
nil
{
tlog
.
Error
(
"get version "
,
"err"
,
err
)
BityuanFlag
=
false
return
err
}
if
!
strings
.
Contains
(
v
.
App
,
"6.3"
)
{
tlog
.
Info
(
"bityuan do not need update"
,
"version"
,
v
.
App
)
BityuanFlag
=
false
return
nil
}
stderr
:=
bytes
.
NewBuffer
(
nil
)
absPath
:=
GetAbsPath
(
setting
.
BityuanSetting
.
Name
)
+
"/"
name
:=
setting
.
BityuanSetting
.
Name
+
"_6.4.0.tar.gz"
url
:=
setting
.
Chain33Pai
.
DownloadUrl
+
name
tlog
.
Info
(
"UpdateNode"
,
"dir"
,
name
)
tlog
.
Info
(
"UpdateNode"
,
"path"
,
absPath
)
err
:
=
DownLoadFile
(
url
,
name
,
int32
(
1
))
err
=
DownLoadFile
(
url
,
name
,
int32
(
1
))
if
err
!=
nil
{
tlog
.
Error
(
"updateBityuan640"
,
"err"
,
err
)
BityuanFlag
=
false
...
...
@@ -656,7 +677,8 @@ func updateBityuan640() error {
BityuanFlag
=
false
return
err
}
//其他模块可能没有即时关闭,在高速刷盘的情形下
time
.
Sleep
(
time
.
Second
*
2
)
remove
:=
exec
.
Command
(
"rm"
,
"-rf"
,
name
)
remove
.
Stderr
=
stderr
err
=
remove
.
Start
()
...
...
@@ -681,3 +703,19 @@ func updateBityuan640() error {
BityuanFlag
=
false
return
nil
}
func
GetNodeUpdateStatus
()
bool
{
var
buf
bytes
.
Buffer
cmd
:=
exec
.
Command
(
"netstat"
,
"-tunlp"
)
cmd
.
Stdout
=
&
buf
err
:=
cmd
.
Run
()
if
err
!=
nil
{
return
false
}
//程序运行 + 端口没开启
if
strings
.
Contains
(
buf
.
String
(),
"v7-bityuan"
)
&&
!
strings
.
Contains
(
buf
.
String
(),
":8801"
)
&&
strings
.
Contains
(
buf
.
String
(),
":6060"
)
{
return
true
}
else
if
!
strings
.
Contains
(
buf
.
String
(),
"v7-bityuan"
)
{
return
false
}
return
false
}
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