mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
7b4c3fc085
closes #8342 - no need to add a migration, because when we'released 1.0, OAuth was never an option - it was disabled in April, 1.0-beta was released in June - remove all remote authentication code
104 lines
3.2 KiB
JavaScript
104 lines
3.2 KiB
JavaScript
// # Bootup
|
|
// This file needs serious love & refactoring
|
|
|
|
/**
|
|
* make sure overrides get's called first!
|
|
* - keeping the overrides require here works for installing Ghost as npm!
|
|
*
|
|
* the call order is the following:
|
|
* - root index requires core module
|
|
* - core index requires server
|
|
* - overrides is the first package to load
|
|
*/
|
|
require('./overrides');
|
|
|
|
// Module dependencies
|
|
var debug = require('ghost-ignition').debug('boot:init'),
|
|
// Config should be first require, as it triggers the initial load of the config files
|
|
config = require('./config'),
|
|
Promise = require('bluebird'),
|
|
i18n = require('./i18n'),
|
|
models = require('./models'),
|
|
permissions = require('./permissions'),
|
|
apps = require('./apps'),
|
|
auth = require('./auth'),
|
|
dbHealth = require('./data/db/health'),
|
|
xmlrpc = require('./data/xml/xmlrpc'),
|
|
slack = require('./data/slack'),
|
|
GhostServer = require('./ghost-server'),
|
|
scheduling = require('./adapters/scheduling'),
|
|
settings = require('./settings'),
|
|
themes = require('./themes'),
|
|
utils = require('./utils');
|
|
|
|
// ## Initialise Ghost
|
|
function init() {
|
|
debug('Init Start...');
|
|
|
|
var ghostServer, parentApp;
|
|
|
|
// Initialize Internationalization
|
|
i18n.init();
|
|
debug('I18n done');
|
|
models.init();
|
|
debug('models done');
|
|
|
|
return dbHealth.check().then(function () {
|
|
debug('DB health check done');
|
|
// Populate any missing default settings
|
|
// Refresh the API settings cache
|
|
return settings.init();
|
|
}).then(function () {
|
|
debug('Update settings cache done');
|
|
// Initialize the permissions actions and objects
|
|
return permissions.init();
|
|
}).then(function () {
|
|
debug('Permissions done');
|
|
return Promise.join(
|
|
themes.init(),
|
|
// Initialize apps
|
|
apps.init(),
|
|
// Initialize xmrpc ping
|
|
xmlrpc.listen(),
|
|
// Initialize slack ping
|
|
slack.listen()
|
|
);
|
|
}).then(function () {
|
|
debug('Apps, XMLRPC, Slack done');
|
|
|
|
// Setup our collection of express apps
|
|
parentApp = require('./app')();
|
|
|
|
// Initialise analytics events
|
|
if (config.get('segment:key')) {
|
|
require('./analytics-events').init();
|
|
}
|
|
|
|
debug('Express Apps done');
|
|
}).then(function () {
|
|
parentApp.use(auth.init());
|
|
debug('Auth done');
|
|
|
|
return new GhostServer(parentApp);
|
|
}).then(function (_ghostServer) {
|
|
ghostServer = _ghostServer;
|
|
|
|
// scheduling can trigger api requests, that's why we initialize the module after the ghost server creation
|
|
// scheduling module can create x schedulers with different adapters
|
|
debug('Server done');
|
|
return scheduling.init({
|
|
schedulerUrl: config.get('scheduling').schedulerUrl,
|
|
active: config.get('scheduling').active,
|
|
apiUrl: utils.url.urlFor('api', true),
|
|
internalPath: config.get('paths').internalSchedulingPath,
|
|
contentPath: config.getContentPath('scheduling')
|
|
});
|
|
}).then(function () {
|
|
debug('Scheduling done');
|
|
debug('...Init End');
|
|
return ghostServer;
|
|
});
|
|
}
|
|
|
|
module.exports = init;
|