mirror of
https://github.com/fosrl/newt.git
synced 2026-04-03 16:36:40 +00:00
Send health checks to the server on reconnect
This commit is contained in:
26
main.go
26
main.go
@@ -1820,6 +1820,30 @@ persistent_keepalive_interval=5`, util.FixKey(privateKey.String()), util.FixKey(
|
|||||||
} else {
|
} else {
|
||||||
logger.Warn("CLIENTS WILL NOT WORK ON THIS VERSION OF NEWT WITH THIS VERSION OF PANGOLIN, PLEASE UPDATE THE SERVER TO 1.13 OR HIGHER OR DOWNGRADE NEWT")
|
logger.Warn("CLIENTS WILL NOT WORK ON THIS VERSION OF NEWT WITH THIS VERSION OF PANGOLIN, PLEASE UPDATE THE SERVER TO 1.13 OR HIGHER OR DOWNGRADE NEWT")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendBlueprint(client)
|
||||||
|
} else {
|
||||||
|
// Resend current health check status for all targets in case the server
|
||||||
|
// missed updates while newt was disconnected.
|
||||||
|
targets := healthMonitor.GetTargets()
|
||||||
|
if len(targets) > 0 {
|
||||||
|
healthStatuses := make(map[int]interface{})
|
||||||
|
for id, target := range targets {
|
||||||
|
healthStatuses[id] = map[string]interface{}{
|
||||||
|
"status": target.Status.String(),
|
||||||
|
"lastCheck": target.LastCheck.Format(time.RFC3339),
|
||||||
|
"checkCount": target.CheckCount,
|
||||||
|
"lastError": target.LastError,
|
||||||
|
"config": target.Config,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.Debug("Reconnected: resending health check status for %d targets", len(healthStatuses))
|
||||||
|
if err := client.SendMessage("newt/healthcheck/status", map[string]interface{}{
|
||||||
|
"targets": healthStatuses,
|
||||||
|
}); err != nil {
|
||||||
|
logger.Error("Failed to resend health check status on reconnect: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send registration message to the server for backward compatibility
|
// Send registration message to the server for backward compatibility
|
||||||
@@ -1832,8 +1856,6 @@ persistent_keepalive_interval=5`, util.FixKey(privateKey.String()), util.FixKey(
|
|||||||
"chainId": bcChainId,
|
"chainId": bcChainId,
|
||||||
})
|
})
|
||||||
|
|
||||||
sendBlueprint(client)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Failed to send registration message: %v", err)
|
logger.Error("Failed to send registration message: %v", err)
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user