Move opeartion back to

This commit is contained in:
Alex Holliday committed 2024-10-18 14:21:22 +08:00
1 parent f5265b140c
commit 64d2d9b3ce
1 file changed
+7 -3
+7 -3
View File
@@ -138,10 +138,13 @@ class NetworkService {
async handlePing(job) { async handlePing(job) {
let isAlive; let isAlive;
const operation = async () => {
const response = await this.ping.promise.probe(job.data.url);
return response;
};
try { try {
const { responseTime, response } = await this.measureResponseTime( const { responseTime, response } = await this.measureResponseTime(operation);
this.ping.promise.probe(job.data.url)
);
isAlive = response.alive; isAlive = response.alive;
const checkData = { const checkData = {
monitorId: job.data._id, monitorId: job.data._id,
@@ -206,6 +209,7 @@ class NetworkService {
responseTime: error.responseTime, responseTime: error.responseTime,
message, message,
}; };
await this.logAndStoreCheck(checkData, this.db.createCheck);
} finally { } finally {
this.handleStatusUpdate(job, isAlive); this.handleStatusUpdate(job, isAlive);
} }