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
33453ad2
Commit
33453ad2
authored
Apr 23, 2020
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加反馈 无ssh功能
parent
a49df86e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
3 deletions
+71
-3
process.go
pkg/app/process.go
+3
-3
node.go
routers/api/v1/node.go
+64
-0
router.go
routers/router.go
+4
-0
No files found.
pkg/app/process.go
View file @
33453ad2
...
...
@@ -566,12 +566,12 @@ type PaiProcessInfo struct {
}
func
AutoSSHClean
()
error
{
pai
,
err
:=
get
Pai
ProcessInfo
()
pai
,
err
:=
get
AutoSSH
ProcessInfo
()
if
err
!=
nil
{
return
err
}
tlog
.
Info
(
"get
Pai
ProcessInfo"
,
"pai"
,
*
pai
)
tlog
.
Info
(
"get
AutoSSH
ProcessInfo"
,
"pai"
,
*
pai
)
if
pai
.
Stime
>
0
&&
(
time
.
Now
()
.
Unix
()
-
pai
.
Stime
)
>
72
*
3600
&&
pai
.
Pid
>
0
{
err
:=
KillAutoSsh
(
pai
.
Pid
)
...
...
@@ -590,7 +590,7 @@ func KillAutoSsh(pid int32) error {
return
cmd
.
Run
()
}
func
get
Pai
ProcessInfo
()
(
*
PaiProcessInfo
,
error
)
{
func
get
AutoSSH
ProcessInfo
()
(
*
PaiProcessInfo
,
error
)
{
var
pai
PaiProcessInfo
var
buf
bytes
.
Buffer
cmd
:=
exec
.
Command
(
"bash"
,
"-c"
,
"ps -eo pid,lstart,cmd |grep autossh | grep -v grep"
)
...
...
routers/api/v1/node.go
View file @
33453ad2
...
...
@@ -339,6 +339,70 @@ func FeedBack(c *gin.Context){
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
nil
)
}
//反馈信息
func
FeedBackWithoutSSH
(
c
*
gin
.
Context
){
appG
:=
app
.
Gin
{
C
:
c
}
local_keyPair
:=
make
(
map
[
string
]
string
)
results
:=
make
(
map
[
string
]
string
)
keyPairStream
,
_
:=
ioutil
.
ReadAll
(
appG
.
C
.
Request
.
Body
)
err
:=
json
.
Unmarshal
(
keyPairStream
,
&
local_keyPair
)
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
INVALID_PARAMS
,
nil
)
log
.
Println
(
err
)
return
}
local_keyPair
[
"public"
]
=
app
.
GetPubKey
()
keyPairStream
,
_
=
json
.
Marshal
(
local_keyPair
)
resp
,
err
:=
http
.
Post
(
setting
.
Chain33Pai
.
FeedBackUrl
,
"application/json"
,
bytes
.
NewReader
(
keyPairStream
))
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
"网络错误"
)
log
.
Println
(
err
)
return
}
keyPairStream
,
_
=
ioutil
.
ReadAll
(
resp
.
Body
)
//log.Println(string(keyPairStream))
err
=
json
.
Unmarshal
(
keyPairStream
,
&
results
)
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
ENV_ERROR
,
"系统错误"
)
log
.
Println
(
err
)
return
}
if
results
[
"code"
]
==
"200"
{
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
nil
)
return
}
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
nil
)
}
func
FeedBackStatusWithoutSSH
(
c
*
gin
.
Context
){
appG
:=
app
.
Gin
{
C
:
c
}
results
:=
make
(
map
[
string
]
interface
{})
resp
,
err
:=
http
.
Post
(
setting
.
Chain33Pai
.
IsCompleteUrl
,
"application/json"
,
nil
)
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
"网络错误"
)
log
.
Println
(
err
)
return
}
data
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
err
=
json
.
Unmarshal
(
data
,
&
results
)
if
err
!=
nil
{
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
"网络错误"
)
log
.
Println
(
err
)
return
}
if
results
[
"code"
]
==
float64
(
e
.
UNDONE
){
appG
.
Response
(
http
.
StatusOK
,
e
.
UNDONE
,
"未解决"
)
return
}
if
results
[
"msg"
]
==
"ok"
{
appG
.
Response
(
http
.
StatusOK
,
e
.
SUCCESS
,
nil
)
return
}
appG
.
Response
(
http
.
StatusOK
,
e
.
NETWORK_ERROR
,
"网络出错"
)
log
.
Println
(
results
)
}
func
FeedBackStatus
(
c
*
gin
.
Context
){
appG
:=
app
.
Gin
{
C
:
c
}
results
:=
make
(
map
[
string
]
interface
{})
...
...
routers/router.go
View file @
33453ad2
...
...
@@ -42,6 +42,10 @@ func InitRouter() *gin.Engine {
apiv1
.
POST
(
"/feedback"
,
v1
.
FeedBack
)
//反馈处理进度
apiv1
.
POST
(
"/iscomplete"
,
v1
.
FeedBackStatus
)
//反馈信息
apiv1
.
POST
(
"/feedbacknew"
,
v1
.
FeedBackWithoutSSH
)
//反馈处理进度
apiv1
.
POST
(
"/iscompletenew"
,
v1
.
FeedBackStatusWithoutSSH
)
apiv1
.
POST
(
"/escrowpassword"
,
v1
.
EscrowPasswd
)
//pai更新完成用户手动重启设备
//apiv1.POST("/isreboot",v1.IsReBoot)
...
...
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