in src/agent/protocol/grpc/clients/HeartbeatClient.ts [50:86]
start() {
if (this.heartbeatTimer) {
logger.warn(`
The heartbeat timer has already been scheduled,
this may be a potential bug, please consider reporting
this to ${packageInfo.bugs.url}
`);
return;
}
const keepAlivePkg = new InstancePingPkg()
.setService(config.serviceName)
.setServiceinstance(config.serviceInstance);
const instanceProperties = new InstanceProperties()
.setService(config.serviceName)
.setServiceinstance(config.serviceInstance)
.setPropertiesList([
new KeyStringValuePair().setKey('language').setValue('NodeJS'),
new KeyStringValuePair().setKey('OS Name').setValue(os.platform()),
new KeyStringValuePair().setKey('hostname').setValue(os.hostname()),
new KeyStringValuePair().setKey('Process No.').setValue(`${process.pid}`),
]);
this.heartbeatTimer = setInterval(() => {
this.managementServiceClient.reportInstanceProperties(instanceProperties, AuthInterceptor(), (error, _) => {
if (error) {
logger.error('Failed to send heartbeat', error);
}
});
this.managementServiceClient.keepAlive(keepAlivePkg, AuthInterceptor(), (error, _) => {
if (error) {
logger.error('Failed to send heartbeat', error);
}
});
}, 20000).unref();
}