0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Allow maintenance mode to be set in config.js (#7124)

refs #6976, #7019, #7125

- Ensure maintenance mode flag is set back to what is in config.js rather than defaulted to false on boot
- Remove stack trace from 503 errors
- Add error message to 503 error
- Ensure error page is rendered for Ghost-Admin on reload with 503
This commit is contained in:
Hannah Wolfe 2016-07-25 20:28:35 +01:00 committed by Katharina Irrgang
parent db145b4019
commit d08926c347
5 changed files with 13 additions and 5 deletions

View file

@ -324,7 +324,8 @@ errors = {
function renderErrorInt(errorView) {
var stack = null;
if (statusCode !== 404 && process.env.NODE_ENV !== 'production' && err.stack) {
// Not Found and Maintenance Errors don't need a stack trace
if (statusCode !== 404 && statusCode !== 503 && process.env.NODE_ENV !== 'production' && err.stack) {
stack = parseStack(err.stack);
}

View file

@ -69,6 +69,7 @@ function init(options) {
}).then(function () {
return versioning.getDatabaseVersion()
.then(function (currentVersion) {
var maintenanceState = config.maintenance.enabled || false;
config.maintenance.enabled = true;
migrations.update({
@ -76,7 +77,7 @@ function init(options) {
toVersion: versioning.getNewestDatabaseVersion(),
forceMigration: process.env.FORCE_MIGRATION
}).then(function () {
config.maintenance.enabled = false;
config.maintenance.enabled = maintenanceState;
}).catch(function (err) {
errors.logErrorAndExit(err, err.context, err.help);
});

View file

@ -197,7 +197,9 @@ setupMiddleware = function setupMiddleware(blogApp) {
// Mount admin express app to /ghost and set up routes
adminApp.use(redirectToSetup);
adminApp.use(maintenance);
adminApp.use(routes.admin());
blogApp.use('/ghost', adminApp);
// send 503 error page in case of maintenance

View file

@ -1,9 +1,12 @@
var config = require(__dirname + '/../config'),
errors = require(config.paths.corePath + '/server/errors');
var config = require('../config'),
i18n = require('../i18n'),
errors = require('../errors');
module.exports = function (req, res, next) {
if (config.maintenance.enabled) {
return next(new errors.Maintenance());
return next(new errors.Maintenance(
i18n.t('errors.general.maintenance')
));
}
next();

View file

@ -170,6 +170,7 @@
}
},
"general": {
"maintenance": "Ghost is currently undergoing maintenance, please wait a moment then retry.",
"moreInfo": "\nMore info: {info}",
"requiredOnFuture": "This will be required in future. Please see {link}"
},