From 0d6a6c7a8a60435d26e51a398c6ea7d26607b63a Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Sun, 28 Feb 2021 00:41:53 -0600 Subject: [PATCH] Cleanup ticking intervals --- nullboard.html | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/nullboard.html b/nullboard.html index b3ccedc..258587c 100644 --- a/nullboard.html +++ b/nullboard.html @@ -1325,6 +1325,7 @@ this.databases.push(arguments[i]); } this.deltas = new Deltas(this.cache()); + this.intervals = []; this.scheduleSync(); this.syncCacheWithPrimary(); } @@ -1367,9 +1368,23 @@ scheduleSync() { - setInterval(() => { this.syncDeltas(); }, 10 * 1000); - setInterval(() => { this.syncCacheWithPrimary(); }, 120 * 1000); - setInterval(() => { this.syncReplicasWithCache(); }, 123 * 1000); + this.intervals.push( + setInterval(() => { this.syncDeltas(); }, 10 * 1000) + ); + this.intervals.push( + setInterval(() => { this.syncCacheWithPrimary(); }, 120 * 1000) + ); + this.intervals.push( + setInterval(() => { this.syncReplicasWithCache(); }, 123 * 1000) + ); + } + + close() + { + this.intervals.forEach((i) => { + clearInterval(i); + }); + this.intervals = []; } syncDeltas() @@ -3199,6 +3214,13 @@ function setGlobalNamespace(namespace) { + try + { + if (globalStorage && globalStorage.close) + globalStorage.close(); + } + catch (e) {} + globalStorage = new MultiDatabase( new NamespacedDatabase(namespace, new HTTPCRUD()), new NamespacedDatabase(namespace, new Local()),