Merge pull request #3044 from bluewave-labs/fix/cache-dns

add cacheable dns, stagger start times
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-10-29 01:17:22 -07:00
commit a9a8686295
3 files changed
+18 -3

No files matched your search

+2 -1
View File
@@ -25,6 +25,7 @@
"axios": "^1.7.2",
"bcryptjs": "3.0.2",
"bullmq": "5.41.2",
"cacheable-lookup": "7.0.0",
"compression": "1.8.1",
"cookie-parser": "^1.4.7",
"cors": "^2.8.5",
@@ -51,7 +52,7 @@
"ping": "0.4.4",
"sharp": "0.33.5",
"ssl-checker": "2.0.10",
"super-simple-scheduler": "1.4.4",
"super-simple-scheduler": "1.4.5",
"swagger-ui-express": "5.0.1",
"winston": "^3.13.0"
},
@@ -35,8 +35,12 @@ class SuperSimpleQueue {
this.scheduler.addTemplate("monitor-job", this.helper.getMonitorJob());
const monitors = await this.db.monitorModule.getAllMonitors();
for (const monitor of monitors) {
await this.addJob(monitor._id, monitor);
const randomOffset = Math.floor(Math.random() * monitor.interval);
setTimeout(() => {
this.addJob(monitor);
}, randomOffset);
}
return true;
} catch (error) {
this.logger.error({
@@ -1,3 +1,4 @@
import CacheableLookup from "cacheable-lookup";
const SERVICE_NAME = "NetworkService";
class NetworkService {
@@ -15,7 +16,6 @@ class NetworkService {
this.NETWORK_ERROR = 5000;
this.PING_ERROR = 5001;
this.axios = axios;
this.got = got;
this.https = https;
this.jmespath = jmespath;
this.GameDig = GameDig;
@@ -26,6 +26,16 @@ class NetworkService {
this.net = net;
this.stringService = stringService;
this.settingsService = settingsService;
const cacheable = new CacheableLookup();
this.got = got.extend({
dnsCache: cacheable,
timeout: {
request: 30000,
},
retry: { limit: 1 },
});
}
// Helper functions