Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
power-node
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
power-node
Commits
98c3e693
Commit
98c3e693
authored
Mar 22, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Plain Diff
merge master
parents
356c2d3b
8a5d323b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
19 deletions
+40
-19
config.go
conf/config.go
+18
-17
config.json
config.json
+2
-1
model_handler.go
nm/model_handler.go
+1
-1
start.go
nm/start.go
+1
-0
task_msg.go
nm/task_msg.go
+18
-0
No files found.
conf/config.go
View file @
98c3e693
...
...
@@ -9,23 +9,24 @@ import (
)
type
Config
struct
{
SignPrv
string
SignPub
string
DockerServer
string
BenefitAddress
string
HeartRespTimeMillis
int64
ExternalIp
string
SignPublicAddress
common
.
Address
SignPrivateKey
*
ecdsa
.
PrivateKey
NmSeed
string
`json:"nm_seed"`
HeartRespTimeSecond
int64
`json:"heart_response"`
TaskValidatorTime
float64
`json:"task_validator_time"`
ContainerNum
int64
`json:"container_num"`
NodeManagerNum
int64
`json:"node_manager_num"`
ChainID
int64
`json:"chain_id"`
ApiUrl
string
`json:"api_url"`
ValidatorUrl
string
`json:"validator_url"`
OssUrl
string
`json:"oss_url"`
SignPrv
string
SignPub
string
DockerServer
string
BenefitAddress
string
HeartRespTimeMillis
int64
ExternalIp
string
SignPublicAddress
common
.
Address
SignPrivateKey
*
ecdsa
.
PrivateKey
NmSeed
string
`json:"nm_seed"`
HeartRespTimeSecond
int64
`json:"heart_response"`
TaskValidatorTime
float64
`json:"task_validator_time"`
ContainerNum
int64
`json:"container_num"`
NodeManagerNum
int64
`json:"node_manager_num"`
ChainID
int64
`json:"chain_id"`
ApiUrl
string
`json:"api_url"`
ValidatorUrl
string
`json:"validator_url"`
OssUrl
string
`json:"oss_url"`
WaitLastTaskExecTime
int64
`json:"wait_last_task_exec_time"`
}
var
_cfg
*
Config
=
nil
...
...
config.json
View file @
98c3e693
...
...
@@ -7,5 +7,6 @@
"container_num"
:
1
,
"chain_id"
:
100
,
"validator_url"
:
"18.167.203.17:20011"
,
"oss_url"
:
"https://tmp-file.agicoin.ai/api/v1/upload"
"oss_url"
:
"https://tmp-file.agicoin.ai/api/v1/upload"
,
"wait_last_task_exec_time"
:
10
}
\ No newline at end of file
nm/model_handler.go
View file @
98c3e693
...
...
@@ -15,7 +15,7 @@ import (
func
monitorModelInfo
(
dockerOp
*
operate
.
DockerOp
)
{
client
:=
&
http
.
Client
{}
ticker
:=
time
.
NewTicker
(
time
.
Second
*
1
)
ticker
:=
time
.
NewTicker
(
time
.
Second
*
1
0
)
for
{
select
{
case
<-
ticker
.
C
:
...
...
nm/start.go
View file @
98c3e693
...
...
@@ -182,6 +182,7 @@ func monitorWorker(op *operate.DockerOp) {
msgRespWorker
.
RegisterMsgResp
(
nodeManager
,
worker
,
RegisterInfoResp
,
nil
)
time
.
Sleep
(
time
.
Second
*
2
)
msgRespWorker
.
RegisterMsgResp
(
nodeManager
,
worker
,
DeviceInfoResp
,
nil
)
op
.
ModelTaskIdIndexesChan
<-
op
.
ReportTaskIds
isSend
=
true
log
.
Info
(
"------------------------Send once-off message ended------------------------"
)
}
...
...
nm/task_msg.go
View file @
98c3e693
...
...
@@ -374,6 +374,13 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage)
apiResBody
:=
utils
.
EncodeJsonEscapeHTML
(
apiRes
)
taskExecResult
.
TaskRespBody
=
apiResBody
}
}
else
{
taskExecResult
.
TaskExecError
=
fmt
.
Sprintf
(
"worker:%s,%s"
,
conf
.
GetConfig
()
.
SignPublicAddress
.
Hex
(),
"Container resp ouput is nil"
)
t
.
ExecTaskIdIsSuccess
.
Store
(
taskMsg
.
TaskId
,
true
)
apiRes
:=
make
([]
string
,
0
)
apiResBody
:=
utils
.
EncodeJsonEscapeHTML
(
apiRes
)
taskExecResult
.
TaskRespBody
=
apiResBody
return
}
}
}
...
...
@@ -577,7 +584,14 @@ func (t *TaskHandler) checkLastTaskExecStatus(taskMsg *nodeManagerV1.PushTaskMes
t
.
IsExecStandardTask
=
true
}
if
oldTaskId
!=
taskMsg
.
TaskId
{
now
:=
time
.
Now
()
for
{
since
:=
time
.
Since
(
now
)
if
int64
(
since
.
Seconds
())
>
conf
.
GetConfig
()
.
WaitLastTaskExecTime
{
log
.
WithField
(
"taskId"
,
oldTaskId
)
.
Info
(
"Waiting for last task execution ending"
)
oldTaskId
=
taskMsg
.
TaskId
break
}
if
oldTaskId
==
""
{
oldTaskId
=
taskMsg
.
TaskId
break
...
...
@@ -652,6 +666,10 @@ func parseData(readBody []byte) interface{} {
log
.
WithError
(
err
)
.
Error
(
"Parse json raw message failed"
)
return
bytes
.
NewBuffer
(
readBody
)
.
String
()
}
if
m
[
"output"
]
==
nil
{
log
.
WithField
(
"output"
,
nil
)
.
Warn
(
"The container resp"
)
return
nil
}
var
outputTwoArray
[][]
string
if
err
:=
json
.
Unmarshal
(
m
[
"output"
],
&
outputTwoArray
);
err
!=
nil
{
log
.
WithField
(
"err"
,
err
)
.
Warn
(
"parse two array output filed failed:"
)
...
...
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