Skip to content

Commit 73330f8

Browse files
committedNov 3, 2023
add healthcheck for helper connection
this should also keep the connection alive for as long as it's in use
1 parent c907d96 commit 73330f8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎pkg/device-agent/eventloop.go

+12
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,18 @@ func (das *DeviceAgentServer) EventLoop(programContext context.Context) {
189189
break
190190
}
191191

192+
helperHealthCheckCtx, cancel := context.WithTimeout(programContext, 1*time.Second)
193+
if _, err := das.DeviceHelper.GetSerial(helperHealthCheckCtx, &pb.GetSerialRequest{}); err != nil {
194+
cancel()
195+
196+
das.log.WithError(err).Errorf("Unable to communicate with helper.Shutting down")
197+
das.notifier.Errorf("Unable to communicate with helper. Shutting down.")
198+
199+
das.stateChange <- pb.AgentState_Disconnecting
200+
break
201+
}
202+
cancel()
203+
192204
wg := &sync.WaitGroup{}
193205

194206
total := len(status.GetGateways())

0 commit comments

Comments
 (0)
Please sign in to comment.