2021-06-15 19:01:22 +03:00
|
|
|
const debug = require('@tryghost/debug')('services:apps');
|
2020-03-20 11:58:26 +03:00
|
|
|
const Promise = require('bluebird');
|
2021-06-30 17:24:49 +03:00
|
|
|
const tpl = require('@tryghost/tpl');
|
2021-06-15 17:36:27 +03:00
|
|
|
const logging = require('@tryghost/logging');
|
2020-05-22 21:22:20 +03:00
|
|
|
const errors = require('@tryghost/errors');
|
2020-05-27 20:47:53 +03:00
|
|
|
const config = require('../../../shared/config');
|
2020-03-20 11:58:26 +03:00
|
|
|
const loader = require('./loader');
|
|
|
|
|
2021-06-30 17:24:49 +03:00
|
|
|
const messages = {
|
|
|
|
appWillNotBeLoadedError: 'The app will not be loaded',
|
|
|
|
appWillNotBeLoadedHelp: 'Check with the app creator, or read the app documentation for more details on app requirements'
|
|
|
|
};
|
|
|
|
|
2020-03-20 11:58:26 +03:00
|
|
|
module.exports = {
|
|
|
|
init: function () {
|
|
|
|
debug('init begin');
|
|
|
|
const appsToLoad = config.get('apps:internal');
|
|
|
|
|
|
|
|
return Promise.map(appsToLoad, appName => loader.activateAppByName(appName))
|
|
|
|
.catch(function (err) {
|
2021-12-01 13:22:01 +03:00
|
|
|
logging.error(new errors.InternalServerError({
|
2020-03-20 11:58:26 +03:00
|
|
|
err: err,
|
2021-06-30 17:24:49 +03:00
|
|
|
context: tpl(messages.appWillNotBeLoadedError),
|
|
|
|
help: tpl(messages.appWillNotBeLoadedHelp)
|
2020-03-20 11:58:26 +03:00
|
|
|
}));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|