Files
mc-tracker/src/scanner/scanner.ts
Liam 9c6966f180
All checks were successful
Publish Docker Image / docker (push) Successful in 1m0s
remove old log
2024-01-03 07:52:43 +00:00

28 lines
665 B
TypeScript

import cron from "node-cron";
import { serverManager } from "..";
import Config from "../../data/config.json";
import { logger } from "../utils/logger";
export default class Scanner {
constructor() {
cron.schedule(Config.scanner.updateCron, () => {
this.scanServers();
});
}
/**
* Start a server scan to ping all servers.
*/
private async scanServers(): Promise<void> {
logger.info(`Scanning servers ${serverManager.getServers().length}`);
// ping all servers in parallel
await Promise.all(
serverManager.getServers().map((server) => server.pingServer())
);
logger.info("Finished scanning servers");
}
}