From 8033b90d38c415f1a597cf55ff353669ffe50821 Mon Sep 17 00:00:00 2001 From: Dollerino Date: Tue, 10 Oct 2023 18:02:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A6=D0=98=D0=A2=D0=9A-685=20-=20=D0=9A=D0=BE?= =?UTF-8?q?=D0=BD=D1=82=D1=80=D0=BE=D0=BB=D1=8C=20=D1=81=D0=BE=D0=BE=D1=82?= =?UTF-8?q?=D0=B2=D0=B5=D1=82=D1=81=D1=82=D0=B2=D0=B8=D1=8F=20=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D1=81=D0=B8=D0=B9=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9=20=D0=B8=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.js | 4 +++- config_default.js | 4 +++- core/app.js | 2 ++ modules/parus_oracle_db.js | 28 ++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/config.js b/config.js index eeceda0..be196c4 100644 --- a/config.js +++ b/config.js @@ -14,7 +14,9 @@ let common = { //Релиз сервера приложений sRelease: "2023.08.31", //Таймаут останова сервера (мс) - nTerminateTimeout: 60000 + nTerminateTimeout: 60000, + //Контролировать версию Системы + bControlSystemVersion: false }; //Параметры подключения к БД diff --git a/config_default.js b/config_default.js index 3008000..ce20fd5 100644 --- a/config_default.js +++ b/config_default.js @@ -14,7 +14,9 @@ let common = { //Релиз сервера приложений sRelease: "2023.08.31", //Таймаут останова сервера (мс) - nTerminateTimeout: 60000 + nTerminateTimeout: 60000, + //Контролировать версию Системы + bControlSystemVersion: false }; //Параметры подключения к БД diff --git a/core/app.js b/core/app.js index 9b6311b..6979e8a 100644 --- a/core/app.js +++ b/core/app.js @@ -202,6 +202,8 @@ class ParusAppServer { this.dbConn = new db.DBConnector({ connectSettings: { ...prms.config.dbConnect, + sRelease: prms.config.common.sRelease, + bControlSystemVersion: prms.config.common.bControlSystemVersion, nPoolMin: prms.config.inComing.nPoolMin, nPoolMax: prms.config.inComing.nPoolMax, nPoolIncrement: prms.config.inComing.nPoolIncrement, diff --git a/modules/parus_oracle_db.js b/modules/parus_oracle_db.js index 54a46b8..f032aa3 100644 --- a/modules/parus_oracle_db.js +++ b/modules/parus_oracle_db.js @@ -70,6 +70,31 @@ const checkWorkers = async prms => { } }; +//Проверка соответствия релизов сервера приложений и системы +const checkRelease = async prms => { + let pooledConnection; + try { + pooledConnection = await prms.connection.getConnection(); + let res = await pooledConnection.execute("BEGIN :DB_RELEASE := PKG_EXS.UTL_PRODUCT_RELEASE_GET(); END;", { + DB_RELEASE: { dir: oracledb.BIND_OUT, type: oracledb.DB_TYPE_VARCHAR } + }); + let sDB_RELEASE = res.outBinds.DB_RELEASE; + if (sDB_RELEASE !== prms.sRelease) { + throw new Error(`Версия сервера приложений (${prms.sRelease}) не соответствует версии системы (${sDB_RELEASE}).`); + } + } catch (e) { + throw new Error(e.message); + } finally { + if (pooledConnection) { + try { + await pooledConnection.close(); + } catch (e) { + throw new Error(e.message); + } + } + } +} + //Подключение к БД const connect = async prms => { try { @@ -93,6 +118,9 @@ const connect = async prms => { ); } }); + if (prms.bControlSystemVersion) { + await checkRelease({ sRelease: prms.sRelease, connection: pool }); + } await checkWorkers({ nMaxWorkers: prms.nMaxWorkers, connection: pool }); return pool; } catch (e) {