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
1b67b83c
Commit
1b67b83c
authored
Mar 12, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor nm heart status
parent
b1a9a5c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
node_manager.go
models/node_manager.go
+3
-3
start.go
nm/start.go
+2
-2
No files found.
models/node_manager.go
View file @
1b67b83c
...
...
@@ -79,7 +79,7 @@ type BenefitAddressInfo struct {
type
NodeManagerClient
struct
{
mutex
sync
.
Mutex
LastHeartTime
int64
LastHeartTime
time
.
Time
PublicKey
string
Endpoint
string
Client
nodeManagerV1
.
NodeManagerServiceClient
...
...
@@ -88,13 +88,13 @@ type NodeManagerClient struct {
IsSelected
bool
}
func
(
n
*
NodeManagerClient
)
GetLastHeartTime
()
int64
{
func
(
n
*
NodeManagerClient
)
GetLastHeartTime
()
time
.
Time
{
n
.
mutex
.
Lock
()
defer
n
.
mutex
.
Unlock
()
return
n
.
LastHeartTime
}
func
(
n
*
NodeManagerClient
)
UpdateLastHeartTime
(
time
int64
)
{
func
(
n
*
NodeManagerClient
)
UpdateLastHeartTime
(
time
time
.
Time
)
{
n
.
mutex
.
Lock
()
n
.
LastHeartTime
=
time
n
.
mutex
.
Unlock
()
...
...
nm/start.go
View file @
1b67b83c
...
...
@@ -195,7 +195,7 @@ func monitorWorker(op *operate.DockerOp) {
log
.
Info
(
"------------------------Start rev msg worker thread------------------------"
)
for
{
if
(
time
.
Now
()
.
UnixMilli
()
-
nodeManager
.
GetLastHeartTime
())
/
conf
.
GetConfig
()
.
HeartRespTimeMillis
>
conf
.
GetConfig
()
.
HeartRespTimeSecond
{
if
time
.
Now
()
.
Sub
(
nodeManager
.
GetLastHeartTime
())
==
time
.
Duration
(
conf
.
GetConfig
()
.
HeartRespTimeSecond
)
{
if
nodeManager
.
Status
{
nodeManager
.
UpdateStatus
(
false
)
}
...
...
@@ -268,7 +268,7 @@ func handlerMsg(nodeManager *models.NodeManagerClient,
}
heartbeatReq
:=
rev
.
GetHeartbeatRequest
()
if
heartbeatReq
!=
nil
{
nodeManager
.
UpdateLastHeartTime
(
int64
(
heartbeatReq
.
Timestamp
))
nodeManager
.
UpdateLastHeartTime
(
time
.
Now
(
))
params
:=
buildParams
(
heartbeatReq
.
Timestamp
)
msgRespWorker
.
RegisterMsgResp
(
nodeManager
,
worker
,
HeartbeatResp
,
params
)
log
.
Info
(
"-------------Heart beat req:-------------"
,
heartbeatReq
)
...
...
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