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
73101c53
Commit
73101c53
authored
Jan 08, 2020
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sprint to sprintf and add app log
parent
f2ab9571
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
process.go
pkg/app/process.go
+14
-12
node.go
routers/api/v1/node.go
+1
-1
No files found.
pkg/app/process.go
View file @
73101c53
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"io"
"io"
"log"
"
github.com/33cn/chain33/common/
log"
"net/http"
"net/http"
"os"
"os"
"os/exec"
"os/exec"
...
@@ -20,6 +20,8 @@ import (
...
@@ -20,6 +20,8 @@ import (
"chain33-pai/pkg/e"
"chain33-pai/pkg/e"
)
)
var
tlog
=
log
.
New
(
"pkg"
,
"app"
)
type
ProcessInfo
struct
{
type
ProcessInfo
struct
{
PName
string
`json:"p_name"`
PName
string
`json:"p_name"`
Pid
string
`json:"pid"`
Pid
string
`json:"pid"`
...
@@ -80,7 +82,7 @@ func getProcessInfo(keyfile string)string{
...
@@ -80,7 +82,7 @@ func getProcessInfo(keyfile string)string{
func
getWalletInfo
()
error
{
func
getWalletInfo
()
error
{
rawProcessInfo
:=
getProcessInfo
(
setting
.
BityuanSetting
.
Name
)
rawProcessInfo
:=
getProcessInfo
(
setting
.
BityuanSetting
.
Name
)
log
.
Println
(
"getWalletInfo"
,
rawProcessInfo
)
tlog
.
Info
(
"getWalletInfo"
,
rawProcessInfo
)
if
rawProcessInfo
==
""
{
if
rawProcessInfo
==
""
{
//钱包节点未启动
//钱包节点未启动
StartProcess
(
setting
.
Chain33Pai
.
Auto
)
StartProcess
(
setting
.
Chain33Pai
.
Auto
)
...
@@ -90,13 +92,13 @@ func getWalletInfo()error{
...
@@ -90,13 +92,13 @@ func getWalletInfo()error{
cmd
.
Start
()
cmd
.
Start
()
cmd
.
Wait
()
cmd
.
Wait
()
if
buffer
.
String
()
==
""
{
if
buffer
.
String
()
==
""
{
log
.
Println
(
"node dose not exist"
)
tlog
.
Info
(
"node dose not exist"
)
return
fmt
.
Errorf
(
"node dose not exist"
)
return
fmt
.
Errorf
(
"node dose not exist"
)
}
else
{
}
else
{
fmt
.
Println
(
buffer
.
String
())
fmt
.
Println
(
buffer
.
String
())
rawProcessInfo
=
getProcessInfo
(
setting
.
BityuanSetting
.
Name
)
rawProcessInfo
=
getProcessInfo
(
setting
.
BityuanSetting
.
Name
)
if
rawProcessInfo
==
""
{
if
rawProcessInfo
==
""
{
log
.
Println
(
"node down"
)
tlog
.
Info
(
"node down"
)
return
errors
.
New
(
"node down"
)
return
errors
.
New
(
"node down"
)
}
}
}
}
...
@@ -175,7 +177,7 @@ func DownLoadLatestVersion()error{
...
@@ -175,7 +177,7 @@ func DownLoadLatestVersion()error{
git
.
Start
()
git
.
Start
()
err
:=
git
.
Wait
()
err
:=
git
.
Wait
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
err
)
tlog
.
Info
(
"DownLoadLatestVersion"
,
"git err"
,
err
)
return
errors
.
New
(
"download latest version failed"
)
return
errors
.
New
(
"download latest version failed"
)
}
}
os
.
Chdir
(
"./"
+
setting
.
BityuanSetting
.
Name
)
os
.
Chdir
(
"./"
+
setting
.
BityuanSetting
.
Name
)
...
@@ -184,7 +186,7 @@ func DownLoadLatestVersion()error{
...
@@ -184,7 +186,7 @@ func DownLoadLatestVersion()error{
makeb
.
Start
()
makeb
.
Start
()
err
=
makeb
.
Wait
()
err
=
makeb
.
Wait
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
err
)
tlog
.
Info
(
"DownLoadLatestVersion"
,
"build err"
,
err
)
return
errors
.
New
(
"failed to compile latest version for some reason"
)
return
errors
.
New
(
"failed to compile latest version for some reason"
)
}
}
return
nil
return
nil
...
@@ -200,13 +202,13 @@ func StartProcess(scriptsAddr string)(err error){
...
@@ -200,13 +202,13 @@ func StartProcess(scriptsAddr string)(err error){
cmd
:=
exec
.
Command
(
scriptsAddr
)
cmd
:=
exec
.
Command
(
scriptsAddr
)
err
=
cmd
.
Start
()
err
=
cmd
.
Start
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
err
)
tlog
.
Info
(
"StartProcess"
,
"exec shell err"
,
err
)
return
return
}
}
err
=
cmd
.
Wait
()
err
=
cmd
.
Wait
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
err
)
tlog
.
Info
(
"StartProcess"
,
"exec shell err"
,
err
)
return
return
}
}
return
return
...
@@ -220,20 +222,20 @@ func MonitorServer() error {
...
@@ -220,20 +222,20 @@ func MonitorServer() error {
stdout
,
err
:=
cmd
.
StdoutPipe
()
stdout
,
err
:=
cmd
.
StdoutPipe
()
err
=
cmd
.
Start
()
err
=
cmd
.
Start
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"MonitorServer"
,
"df -T start "
,
err
)
tlog
.
Info
(
"MonitorServer"
,
"df -T start "
,
err
)
return
err
return
err
}
}
content
,
err
:=
ioutil
.
ReadAll
(
stdout
)
content
,
err
:=
ioutil
.
ReadAll
(
stdout
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
err
)
tlog
.
Info
(
"MonitorServer"
,
"ioutil readd err"
,
err
)
return
err
return
err
}
}
err
=
cmd
.
Wait
()
err
=
cmd
.
Wait
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"MonitorServer"
,
"df -T end"
,
err
)
tlog
.
Info
(
"MonitorServer"
,
"df -T end"
,
err
)
return
err
return
err
}
}
log
.
Println
(
"MonitorServer"
,
string
(
content
))
tlog
.
Info
(
"MonitorServer"
,
string
(
content
))
list
:=
strings
.
Split
(
string
(
content
),
"
\n
"
)
list
:=
strings
.
Split
(
string
(
content
),
"
\n
"
)
tempDisk
:=
make
([]
*
Disk
,
0
)
tempDisk
:=
make
([]
*
Disk
,
0
)
for
_
,
v
:=
range
list
{
for
_
,
v
:=
range
list
{
...
...
routers/api/v1/node.go
View file @
73101c53
...
@@ -293,7 +293,7 @@ func ResetNode(c* gin.Context){
...
@@ -293,7 +293,7 @@ func ResetNode(c* gin.Context){
return
return
}
}
err
=
os
.
RemoveAll
(
fmt
.
Sprint
(
"%s/datadir"
,
path
.
Dir
(
app
.
Bityuan
.
Path
)))
err
=
os
.
RemoveAll
(
fmt
.
Sprint
f
(
"%s/datadir"
,
path
.
Dir
(
app
.
Bityuan
.
Path
)))
if
err
!=
nil
{
if
err
!=
nil
{
app
.
BityuanFlag
=
false
app
.
BityuanFlag
=
false
tlog
.
Error
(
"ResetNode"
,
"remove datadir err"
,
err
)
tlog
.
Error
(
"ResetNode"
,
"remove datadir err"
,
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