Merge branch 'develop' into feat/be/hardware-monitor-notifications

This commit is contained in:
Alex Holliday committed 2024-10-25 10:44:30 +08:00
commit cf032859a1
33 files changed
+1658 -654

No files matched your search

+24 -19
View File
@@ -56,10 +56,12 @@ class NetworkService {
}
}
} catch (error) {
this.logger.error(error.message, {
method: "handleNotification",
this.logger.error({
message: error.message,
service: this.SERVICE_NAME,
monitorId: monitor._id,
method: "handleNotification",
details: `notification error for monitor: ${monitor._id}`,
stack: error.stack,
});
}
}
@@ -80,19 +82,18 @@ class NetworkService {
try {
monitor = await this.db.getMonitorById(_id);
} catch (error) {
this.logger.error({
message: error.message,
service: this.SERVICE_NAME,
method: "handleStatusUpdate",
stack: error.stack,
details: `monitor lookup error for monitor: ${_id}`,
});
return;
}
// Otherwise, try to update monitor status
try {
if (monitor === null || monitor === undefined) {
this.logger.error(`Null Monitor: ${_id}`, {
method: "handleStatusUpdate",
service: this.SERVICE_NAME,
jobId: job.id,
});
return;
}
if (monitor.status === undefined || monitor.status !== isAlive) {
const oldStatus = monitor.status;
monitor.status = isAlive;
@@ -113,10 +114,12 @@ class NetworkService {
this.handleHardwareUpdate(monitor, hardwareData);
}
} catch (error) {
this.logger.error(error.message, {
method: "handleStatusUpdate",
this.logger.error({
message: error.message,
service: this.SERVICE_NAME,
jobId: job.id,
method: "handleStatusUpdate",
stack: error.stack,
details: `status update error for monitor: ${_id}`,
});
}
}
@@ -451,11 +454,12 @@ class NetworkService {
case this.TYPE_HARDWARE:
return await this.handleHardware(job);
default:
this.logger.error(`Unsupported type: ${job.data.type}`, {
this.logger.error({
message: `Unsupported type: ${job.data.type}`,
service: this.SERVICE_NAME,
method: "getStatus",
jobId: job.id,
});
return false;
}
}
@@ -477,11 +481,12 @@ class NetworkService {
}
throw new Error();
} catch (error) {
this.logger.error(`Error writing check for ${data.monitorId}`, {
this.logger.error({
message: error.message,
service: this.SERVICE_NAME,
method: "logAndStoreCheck",
monitorId: data.monitorId,
error: error,
details: `Error writing check for ${data.monitorId}`,
stack: error.stack,
});
}
}