diff --git a/src/influx/influx.ts b/src/influx/influx.ts index 5f52f13..8666f8a 100644 --- a/src/influx/influx.ts +++ b/src/influx/influx.ts @@ -14,13 +14,13 @@ export default class Influx { url: Config.influx.url, token: Config.influx.token, }); - logger.info("InfluxDB initialized"); - this.writeApi = this.influx.getWriteApi( Config.influx.org, Config.influx.bucket, "ms" ); + + logger.info("InfluxDB initialized"); } /** @@ -28,7 +28,7 @@ export default class Influx { * * @param point the point to write */ - public async writePoint(point: Point): Promise { + public writePoint(point: Point) { this.writeApi.writePoint(point); } } diff --git a/src/server/server.ts b/src/server/server.ts index 86663d2..c2d66fc 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -179,6 +179,15 @@ export default class Server { }); } + /** + * Invalidates the DNS cache for the server. + */ + public invalidateDns() { + this.dnsInfo = { + hasResolved: false, + }; + } + /** * Returns the name of the server. * diff --git a/src/server/serverManager.ts b/src/server/serverManager.ts index b761847..ea01ef9 100644 --- a/src/server/serverManager.ts +++ b/src/server/serverManager.ts @@ -23,6 +23,13 @@ export default class ServerManager { cron.schedule(Config.pinger.pingCron, () => { this.pingServers(); }); + + cron.schedule(Config.pinger.dnsInvalidationCron, () => { + logger.info("Invalidating DNS cache for all servers"); + for (const server of this.servers) { + server.invalidateDns(); + } + }); } /**