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
d9b292e5
Commit
d9b292e5
authored
Jul 23, 2020
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
fb95fed6
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
28 deletions
+32
-28
broadcast.go
pkg/app/broadcast.go
+0
-2
process.go
pkg/app/process.go
+9
-14
request.go
pkg/app/request.go
+0
-2
response.go
pkg/app/response.go
+0
-1
cmd.go
pkg/cmd/cmd.go
+8
-2
pai.go
pkg/pai/pai.go
+10
-2
node.go
routers/api/v1/node.go
+2
-4
pai.go
service/pai_service/pai.go
+3
-1
No files found.
pkg/app/broadcast.go
View file @
d9b292e5
...
@@ -71,7 +71,6 @@ func Broadcast() {
...
@@ -71,7 +71,6 @@ func Broadcast() {
panic
(
err
)
panic
(
err
)
}
}
tlog
.
Info
(
"broadcast"
,
"oldip"
,
runningAddr
.
IP
.
String
(),
"newip"
,
ip
.
IP
.
String
())
tlog
.
Info
(
"broadcast"
,
"oldip"
,
runningAddr
.
IP
.
String
(),
"newip"
,
ip
.
IP
.
String
())
}
}
runningAddr
=
ip
runningAddr
=
ip
...
@@ -83,7 +82,6 @@ func Broadcast() {
...
@@ -83,7 +82,6 @@ func Broadcast() {
}
}
tlog
.
Info
(
"broadcast"
,
"ip:"
,
ip
.
IP
.
String
(),
"udp"
,
send
)
tlog
.
Info
(
"broadcast"
,
"ip:"
,
ip
.
IP
.
String
(),
"udp"
,
send
)
time
.
Sleep
(
time
.
Second
*
1
)
time
.
Sleep
(
time
.
Second
*
1
)
}
}
}
}
...
...
pkg/app/process.go
View file @
d9b292e5
...
@@ -56,8 +56,6 @@ type BityuanOp struct {
...
@@ -56,8 +56,6 @@ type BityuanOp struct {
Lock
sync
.
Mutex
Lock
sync
.
Mutex
}
}
var
paiJobs
pai_service
.
Pai
var
BityuanFlag
BityuanOp
//true表示有任务在占用,禁止其他重复操作
var
BityuanFlag
BityuanOp
//true表示有任务在占用,禁止其他重复操作
var
Bityuan
ProcessInfo
var
Bityuan
ProcessInfo
var
UpdateInfo
updateInfo
var
UpdateInfo
updateInfo
...
@@ -90,7 +88,6 @@ func getProcessInfo(keyfile string) string {
...
@@ -90,7 +88,6 @@ func getProcessInfo(keyfile string) string {
}
}
func
getWalletInfo
()
error
{
func
getWalletInfo
()
error
{
rawProcessInfo
:=
getProcessInfo
(
setting
.
BityuanSetting
.
Name
)
rawProcessInfo
:=
getProcessInfo
(
setting
.
BityuanSetting
.
Name
)
tlog
.
Info
(
"getWalletInfo"
,
"wallet"
,
rawProcessInfo
)
tlog
.
Info
(
"getWalletInfo"
,
"wallet"
,
rawProcessInfo
)
if
rawProcessInfo
==
""
{
if
rawProcessInfo
==
""
{
...
@@ -148,7 +145,6 @@ func BityuanJob(ticker *time.Ticker) {
...
@@ -148,7 +145,6 @@ func BityuanJob(ticker *time.Ticker) {
NodeError
=
getWalletInfo
()
NodeError
=
getWalletInfo
()
//解锁钱包
//解锁钱包
if
NodeError
==
nil
{
if
NodeError
==
nil
{
status
,
err
:=
GetWalletStatus
()
status
,
err
:=
GetWalletStatus
()
if
err
!=
nil
{
if
err
!=
nil
{
tlog
.
Error
(
"GetWalletStatus"
,
"err"
,
err
)
tlog
.
Error
(
"GetWalletStatus"
,
"err"
,
err
)
...
@@ -166,7 +162,6 @@ func BityuanJob(ticker *time.Ticker) {
...
@@ -166,7 +162,6 @@ func BityuanJob(ticker *time.Ticker) {
// }
// }
//}
//}
}
}
}
}
//升级6.4.0bityuan
//升级6.4.0bityuan
//updateBityuan640()
//updateBityuan640()
...
@@ -535,16 +530,16 @@ func AutoUpdate() {
...
@@ -535,16 +530,16 @@ func AutoUpdate() {
tlog
.
Info
(
"kill restart pai success "
)
tlog
.
Info
(
"kill restart pai success "
)
}
}
}
}
}
else
{
}
else
if
!
DPercent
.
Flag
{
if
!
DPercent
.
Flag
{
//没有其他任务占用
//没有其他任务占用
DPercent
.
Flag
=
true
DPercent
.
Flag
=
true
err
:=
AutoUpdatePai
()
err
:=
AutoUpdatePai
()
if
err
!=
nil
{
if
err
!=
nil
{
tlog
.
Error
(
"autoupdatepai"
,
"err"
,
err
)
tlog
.
Error
(
"autoupdatepai"
,
"err"
,
err
)
}
tlog
.
Info
(
"autoupdatepai"
,
"err"
,
GetVersion
())
DPercent
.
Flag
=
false
}
}
tlog
.
Info
(
"autoupdatepai"
,
"err"
,
GetVersion
())
DPercent
.
Flag
=
false
}
}
}
}
...
...
pkg/app/request.go
View file @
d9b292e5
...
@@ -11,6 +11,4 @@ func MarkErrors(errors []*validation.Error) {
...
@@ -11,6 +11,4 @@ func MarkErrors(errors []*validation.Error) {
for
_
,
err
:=
range
errors
{
for
_
,
err
:=
range
errors
{
logging
.
Info
(
err
.
Key
,
err
.
Message
)
logging
.
Info
(
err
.
Key
,
err
.
Message
)
}
}
return
}
}
pkg/app/response.go
View file @
d9b292e5
...
@@ -23,5 +23,4 @@ func (g *Gin) Response(httpCode, errCode int, data interface{}) {
...
@@ -23,5 +23,4 @@ func (g *Gin) Response(httpCode, errCode int, data interface{}) {
Msg
:
e
.
GetMsg
(
errCode
),
Msg
:
e
.
GetMsg
(
errCode
),
Data
:
data
,
Data
:
data
,
})
})
return
}
}
pkg/cmd/cmd.go
View file @
d9b292e5
...
@@ -5,19 +5,25 @@ import (
...
@@ -5,19 +5,25 @@ import (
"bytes"
"bytes"
"strings"
"strings"
"fmt"
"fmt"
"github.com/33cn/chain33/common/log"
)
)
var
cmdLog
=
log
.
New
(
"pkg"
,
"app"
)
func
GetLocalArchType
()
string
{
func
GetLocalArchType
()
string
{
cmd
:=
exec
.
Command
(
"arch"
)
cmd
:=
exec
.
Command
(
"arch"
)
var
buf
bytes
.
Buffer
var
buf
bytes
.
Buffer
cmd
.
Stdout
=
&
buf
cmd
.
Stdout
=
&
buf
cmd
.
Run
()
err
:=
cmd
.
Run
()
if
err
!=
nil
{
cmdLog
.
Error
(
"GetLocalArchType"
,
"err"
,
err
)
return
""
}
if
buf
.
String
()
!=
""
{
if
buf
.
String
()
!=
""
{
lines
:=
strings
.
Split
(
buf
.
String
(),
"
\n
"
)
lines
:=
strings
.
Split
(
buf
.
String
(),
"
\n
"
)
if
len
(
lines
)
==
2
{
if
len
(
lines
)
==
2
{
return
strings
.
Trim
(
lines
[
0
],
" "
)
return
strings
.
Trim
(
lines
[
0
],
" "
)
}
}
return
""
}
}
return
""
return
""
}
}
...
...
pkg/pai/pai.go
View file @
d9b292e5
...
@@ -56,8 +56,16 @@ func FindAbsPath(name string) string {
...
@@ -56,8 +56,16 @@ func FindAbsPath(name string) string {
var
buffer
bytes
.
Buffer
var
buffer
bytes
.
Buffer
cmd
:=
exec
.
Command
(
"find"
,
"/media"
,
"-name"
,
name
)
cmd
:=
exec
.
Command
(
"find"
,
"/media"
,
"-name"
,
name
)
cmd
.
Stdout
=
&
buffer
cmd
.
Stdout
=
&
buffer
cmd
.
Start
()
err
:=
cmd
.
Start
()
cmd
.
Wait
()
if
err
!=
nil
{
tlog
.
Error
(
"FindAbsPath start"
,
"ERR"
,
err
)
return
""
}
err
=
cmd
.
Wait
()
if
err
!=
nil
{
tlog
.
Error
(
"FindAbsPath wait"
,
"ERR"
,
err
)
return
""
}
if
buffer
.
String
()
==
""
{
if
buffer
.
String
()
==
""
{
tlog
.
Error
(
"FindAbsPath"
,
"ERR"
,
"node path not exists"
)
tlog
.
Error
(
"FindAbsPath"
,
"ERR"
,
"node path not exists"
)
return
""
return
""
...
...
routers/api/v1/node.go
View file @
d9b292e5
...
@@ -23,8 +23,6 @@ import (
...
@@ -23,8 +23,6 @@ import (
"time"
"time"
)
)
var
flag
bool
//判断是否正在更新
func
ResetWallet
(
c
*
gin
.
Context
)
{
func
ResetWallet
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
appG
:=
app
.
Gin
{
C
:
c
}
app
.
BityuanFlag
.
Lock
.
Lock
()
app
.
BityuanFlag
.
Lock
.
Lock
()
...
@@ -86,7 +84,7 @@ func UpdateNodeNew(c *gin.Context) {
...
@@ -86,7 +84,7 @@ func UpdateNodeNew(c *gin.Context) {
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
"get pwd err"
)
appG
.
Response
(
http
.
StatusOK
,
e
.
ERROR
,
"get pwd err"
)
return
return
}
}
pwd
=
pwd
+
"/"
pwd
+=
"/"
app
.
BityuanFlag
.
Flag
=
true
app
.
BityuanFlag
.
Flag
=
true
//app.UpdateInfo.Flag = false
//app.UpdateInfo.Flag = false
setting
.
FreshVersion
()
setting
.
FreshVersion
()
...
@@ -495,12 +493,12 @@ func EscrowPasswd(c *gin.Context) {
...
@@ -495,12 +493,12 @@ func EscrowPasswd(c *gin.Context) {
return
return
}
}
f
,
err
:=
os
.
OpenFile
(
setting
.
BityuanSetting
.
Passwd
,
os
.
O_WRONLY
|
os
.
O_TRUNC
|
os
.
O_CREATE
,
0666
)
f
,
err
:=
os
.
OpenFile
(
setting
.
BityuanSetting
.
Passwd
,
os
.
O_WRONLY
|
os
.
O_TRUNC
|
os
.
O_CREATE
,
0666
)
defer
f
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
ENV_ERROR
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
ENV_ERROR
,
nil
)
tlog
.
Info
(
err
.
Error
())
tlog
.
Info
(
err
.
Error
())
return
return
}
}
defer
f
.
Close
()
f
.
WriteString
(
passwd
.
Password
)
f
.
WriteString
(
passwd
.
Password
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
nil
)
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
nil
)
...
...
service/pai_service/pai.go
View file @
d9b292e5
...
@@ -159,7 +159,7 @@ func (p *Pai) GetDevstatus() error {
...
@@ -159,7 +159,7 @@ func (p *Pai) GetDevstatus() error {
func
getPaiConfig
(
command
string
,
arg
...
string
)
(
config
map
[
string
]
string
,
err
error
)
{
func
getPaiConfig
(
command
string
,
arg
...
string
)
(
config
map
[
string
]
string
,
err
error
)
{
//获取操作系统版本信息
//获取操作系统版本信息
list
:=
make
(
map
[
string
]
string
,
0
)
list
:=
make
(
map
[
string
]
string
)
cmd
:=
exec
.
Command
(
"cat"
,
arg
...
)
cmd
:=
exec
.
Command
(
"cat"
,
arg
...
)
stdout
,
err
:=
cmd
.
StdoutPipe
()
stdout
,
err
:=
cmd
.
StdoutPipe
()
//tlog.Info(stdout)
//tlog.Info(stdout)
...
@@ -204,12 +204,14 @@ func (p *Pai) GetPaiLatestVersion(t int32) (string, error) {
...
@@ -204,12 +204,14 @@ func (p *Pai) GetPaiLatestVersion(t int32) (string, error) {
bytesData
,
_
:=
json
.
Marshal
(
data
)
bytesData
,
_
:=
json
.
Marshal
(
data
)
resp
,
err
:=
http
.
Post
(
setting
.
Chain33Pai
.
VersionUrl
,
"application/json"
,
bytes
.
NewReader
(
bytesData
))
resp
,
err
:=
http
.
Post
(
setting
.
Chain33Pai
.
VersionUrl
,
"application/json"
,
bytes
.
NewReader
(
bytesData
))
if
err
!=
nil
{
if
err
!=
nil
{
resp
.
Close
()
return
""
,
err
return
""
,
err
}
}
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
type
res
struct
{
type
res
struct
{
Code
int64
Code
int64
Msg
string
Msg
string
...
...
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