[BREAK] Prevent start if incompatible mongo version (#13927)

* Show mongo version

* Switch to proper mongo version check.  Warn if not at least 3.2
pull/13824/head^2
Aaron Ogle 6 years ago committed by Rodrigo Nascimento
parent b0d71bc943
commit 59e5e92aae
  1. 31
      server/startup/serverRunning.js

@ -9,13 +9,25 @@ import semver from 'semver';
Meteor.startup(function() { Meteor.startup(function() {
let oplogState = 'Disabled'; let oplogState = 'Disabled';
if (MongoInternals.defaultRemoteCollectionDriver().mongo._oplogHandle && MongoInternals.defaultRemoteCollectionDriver().mongo._oplogHandle.onOplogEntry) {
const { mongo } = MongoInternals.defaultRemoteCollectionDriver();
if (mongo._oplogHandle && mongo._oplogHandle.onOplogEntry) {
oplogState = 'Enabled'; oplogState = 'Enabled';
if (settings.get('Force_Disable_OpLog_For_Cache') === true) { if (settings.get('Force_Disable_OpLog_For_Cache') === true) {
oplogState += ' (Disabled for Cache Sync)'; oplogState += ' (Disabled for Cache Sync)';
} }
} }
let mongoDbVersion;
try {
const { version } = Promise.await(mongo.db.command({ buildInfo: 1 }));
mongoDbVersion = version;
} catch (e) {
mongoDbVersion = 'Error getting version';
console.error('Error getting MongoDB version');
}
const desiredNodeVersion = semver.clean(fs.readFileSync(path.join(process.cwd(), '../../.node_version.txt')).toString()); const desiredNodeVersion = semver.clean(fs.readFileSync(path.join(process.cwd(), '../../.node_version.txt')).toString());
const desiredNodeVersionMajor = String(semver.parse(desiredNodeVersion).major); const desiredNodeVersionMajor = String(semver.parse(desiredNodeVersion).major);
@ -23,6 +35,7 @@ Meteor.startup(function() {
let msg = [ let msg = [
`Rocket.Chat Version: ${ Info.version }`, `Rocket.Chat Version: ${ Info.version }`,
` NodeJS Version: ${ process.versions.node } - ${ process.arch }`, ` NodeJS Version: ${ process.versions.node } - ${ process.arch }`,
` MongoDB Version: ${ mongoDbVersion }`,
` Platform: ${ process.platform }`, ` Platform: ${ process.platform }`,
` Process Port: ${ process.env.PORT }`, ` Process Port: ${ process.env.PORT }`,
` Site URL: ${ settings.get('Site_Url') }`, ` Site URL: ${ settings.get('Site_Url') }`,
@ -39,14 +52,20 @@ Meteor.startup(function() {
msg = msg.join('\n'); msg = msg.join('\n');
if (semver.satisfies(process.versions.node, desiredNodeVersionMajor)) { if (!semver.satisfies(process.versions.node, desiredNodeVersionMajor)) {
return SystemLogger.startup_box(msg, 'SERVER RUNNING'); msg += ['', '', 'YOUR CURRENT NODEJS VERSION IS NOT SUPPORTED,', `PLEASE UPGRADE / DOWNGRADE TO VERSION ${ desiredNodeVersionMajor }.X.X`].join('\n');
SystemLogger.error_box(msg, 'SERVER ERROR');
return process.exit();
} }
msg += ['', '', 'YOUR CURRENT NODEJS VERSION IS NOT SUPPORTED,', `PLEASE UPGRADE / DOWNGRADE TO VERSION ${ desiredNodeVersionMajor }.X.X`].join('\n'); if (!semver.satisfies(mongoDbVersion, '>=3.2.0')) {
msg += ['', '', 'YOUR CURRENT MONGODB VERSION IS NOT SUPPORTED,', 'PLEASE UPGRADE TO VERSION 3.2 OR LATER'].join('\n');
SystemLogger.error_box(msg, 'SERVER ERROR');
SystemLogger.error_box(msg, 'SERVER ERROR'); return process.exit();
}
return process.exit(); return SystemLogger.startup_box(msg, 'SERVER RUNNING');
}, 100); }, 100);
}); });

Loading…
Cancel
Save