mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 07:55:46 +01:00
fix: #7940, run upgrade scripts on startup
This commit is contained in:
27
src/start.js
27
src/start.js
@@ -18,11 +18,11 @@ start.start = async function () {
|
|||||||
await db.init();
|
await db.init();
|
||||||
|
|
||||||
const meta = require('./meta');
|
const meta = require('./meta');
|
||||||
await Promise.all([
|
await db.checkCompatibility();
|
||||||
db.checkCompatibility(),
|
await meta.configs.init();
|
||||||
meta.configs.init(),
|
if (nconf.get('runJobs')) {
|
||||||
require('./upgrade').check(),
|
await runUpgrades();
|
||||||
]);
|
}
|
||||||
|
|
||||||
if (nconf.get('dep-check') === undefined || nconf.get('dep-check') !== false) {
|
if (nconf.get('dep-check') === undefined || nconf.get('dep-check') !== false) {
|
||||||
await meta.dependencies.check();
|
await meta.dependencies.check();
|
||||||
@@ -50,10 +50,6 @@ start.start = async function () {
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
switch (err.message) {
|
switch (err.message) {
|
||||||
case 'schema-out-of-date':
|
|
||||||
winston.error('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:');
|
|
||||||
winston.error(' ./nodebb upgrade');
|
|
||||||
break;
|
|
||||||
case 'dependencies-out-of-date':
|
case 'dependencies-out-of-date':
|
||||||
winston.error('One or more of NodeBB\'s dependent packages are out-of-date. Please run the following command to update them:');
|
winston.error('One or more of NodeBB\'s dependent packages are out-of-date. Please run the following command to update them:');
|
||||||
winston.error(' ./nodebb upgrade');
|
winston.error(' ./nodebb upgrade');
|
||||||
@@ -72,6 +68,19 @@ start.start = async function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function runUpgrades() {
|
||||||
|
const upgrade = require('./upgrade');
|
||||||
|
try {
|
||||||
|
await upgrade.check();
|
||||||
|
} catch (err) {
|
||||||
|
if (err && err.message === 'schema-out-of-date') {
|
||||||
|
await upgrade.run();
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setupConfigs() {
|
function setupConfigs() {
|
||||||
// nconf defaults, if not set in config
|
// nconf defaults, if not set in config
|
||||||
if (!nconf.get('sessionKey')) {
|
if (!nconf.get('sessionKey')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user