You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2018/11/20 20:43:31 UTC
[2/8] ignite git commit: IGNITE-10349 Web Console: Added check for
supported MongoDb version.
IGNITE-10349 Web Console: Added check for supported MongoDb version.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8bd59ccf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8bd59ccf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8bd59ccf
Branch: refs/heads/ignite-10044
Commit: 8bd59ccfff778ba59d55707c5182c09e391c0103
Parents: d6d4965
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Tue Nov 20 23:56:22 2018 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Nov 20 23:56:22 2018 +0700
----------------------------------------------------------------------
modules/web-console/backend/index.js | 10 +++++-----
modules/web-console/backend/launch-tools.js | 20 +++++++++++++++++++-
2 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8bd59ccf/modules/web-console/backend/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/index.js b/modules/web-console/backend/index.js
index 4697de9..c601c0b 100644
--- a/modules/web-console/backend/index.js
+++ b/modules/web-console/backend/index.js
@@ -23,17 +23,17 @@ const appPath = require('app-module-path');
appPath.addPath(__dirname);
appPath.addPath(path.join(__dirname, 'node_modules'));
-const { migrate, init } = require('./launch-tools');
+const { checkMongo, migrate, init } = require('./launch-tools');
const injector = require('./injector');
injector.log.info = () => {};
injector.log.debug = () => {};
-Promise.all([injector('settings'), injector('mongo')])
- .then(([{mongoUrl}]) => {
- return migrate(mongoUrl, 'Ignite', path.join(__dirname, 'migrations'));
- })
+injector('mongo')
+ .then(() => checkMongo())
+ .then(() => injector('settings'))
+ .then(({mongoUrl}) => migrate(mongoUrl, 'Ignite', path.join(__dirname, 'migrations')))
.then(() => Promise.all([injector('settings'), injector('api-server'), injector('agents-handler'), injector('browsers-handler')]))
.then(init)
.catch((err) => {
http://git-wip-us.apache.org/repos/asf/ignite/blob/8bd59ccf/modules/web-console/backend/launch-tools.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/launch-tools.js b/modules/web-console/backend/launch-tools.js
index f1f3b2f..3870b0d 100644
--- a/modules/web-console/backend/launch-tools.js
+++ b/modules/web-console/backend/launch-tools.js
@@ -21,6 +21,7 @@ const _ = require('lodash');
const http = require('http');
const https = require('https');
const MigrateMongoose = require('migrate-mongoose');
+const mongoose = require('mongoose');
/**
* Event listener for HTTP server "error" event.
@@ -106,4 +107,21 @@ const migrate = (dbConnectionUri, group, migrationsPath, collectionName) => {
});
};
-module.exports = { migrate, init };
+/**
+ * Check version of used MongoDB.
+ */
+const checkMongo = () => {
+ const versionValid = (mijor, minor) => mijor === 3 && minor >= 2 && minor <= 4;
+
+ const admin = new mongoose.mongo.Admin(mongoose.connection.db, null, global.Promise);
+
+ return admin.buildInfo()
+ .then((info) => {
+ const versions = info.version.split('.');
+
+ if (!versionValid(parseInt(versions[0]), parseInt(versions[1])))
+ throw Error(`Unsupported version of MongoDB ${info.version}. Supported versions: 3.2.x-3.4.x`);
+ });
+};
+
+module.exports = { checkMongo, migrate, init };