From 69a34b72beff8a42d363ce5bf6aeab39119e2e1f Mon Sep 17 00:00:00 2001 From: Mia <49593536+mia-pi-git@users.noreply.github.com> Date: Tue, 27 Dec 2022 20:47:19 -0600 Subject: [PATCH] Don't set a file watcher on every request --- src/dispatcher.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/dispatcher.ts b/src/dispatcher.ts index a131d96..412a3ce 100644 --- a/src/dispatcher.ts +++ b/src/dispatcher.ts @@ -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(); + } + }); + } }