Don't set a file watcher on every request

This commit is contained in:
Mia 2022-12-27 20:47:19 -06:00
parent fdfebd96e7
commit 69a34b72be

View File

@ -68,12 +68,6 @@ export class Dispatcher {
this.user = new User(this.session);
this.opts = opts;
this.cookies = Dispatcher.parseCookie(this.request.headers.cookie);
fs.watchFile(Config.serverlist, (curr, prev) => {
if (curr.mtime > prev.mtime) {
Dispatcher.loadServers();
}
});
}
async executeActions() {
const {act, body} = this.opts;
@ -261,4 +255,12 @@ export class Dispatcher {
}
return {};
}
static {
fs.watchFile(Config.serverlist, (curr, prev) => {
if (curr.mtime > prev.mtime) {
Dispatcher.loadServers();
}
});
}
}