add auto invalidation of dns cache
Some checks failed
Publish Docker Image / docker (push) Successful in 42s
deploy / deploy (push) Has been cancelled

This commit is contained in:
Lee 2024-01-03 09:46:46 +00:00
parent d841900cfb
commit 88472c81e9
3 changed files with 19 additions and 3 deletions

@ -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<void> {
public writePoint(point: Point) {
this.writeApi.writePoint(point);
}
}

@ -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.
*

@ -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();
}
});
}
/**