From 74bb3f236259123e3291cef4e169bede80a3b654 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 27 Nov 2022 21:31:03 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3=20=D0=B7=D0=B0=D0=BA=D1=80?= =?UTF-8?q?=D1=8B=D1=82=D0=B8=D1=8F=20=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/WebAccess.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/core/WebAccess.js b/server/core/WebAccess.js index a272cb7..6da3548 100644 --- a/server/core/WebAccess.js +++ b/server/core/WebAccess.js @@ -1,6 +1,7 @@ const { JembaDbThread } = require('jembadb'); const utils = require('../core/utils'); const log = new (require('../core/AppLogger'))().log;//singleton +const asyncExit = new (require('./AsyncExit'))(); const cleanPeriod = 1*60*1000;//1 минута const cleanUnusedTokenTimeout = 5*60*1000;//5 минут @@ -13,6 +14,8 @@ class WebAccess { this.accessTimeout = config.accessTimeout*60*1000; this.accessMap = new Map(); + asyncExit.add(this.closeDb.bind(this)); + setTimeout(() => { this.periodicClean(); }, cleanPeriod); } @@ -67,6 +70,13 @@ class WebAccess { this.db = db; } + async closeDb() { + if (this.db) { + await this.db.unlock(); + this.db = null; + } + } + async periodicClean() { while (1) {//eslint-disable-line no-constant-condition try {