mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
⏱ Boot time visibility amends (#7984)
refs #2182 * ⏱ Add boot timer - improve visibility of boot time I've been playing around with Ghost start times a lot recently. Every time I do, I add a console.time output for boot, which is annoying. This commit adds that change permanently. We can always revert later before shipping 1.0 😁 * ⏱ Add debug call before main requires - this demonstrates that the majority of boot time is spent on requires - had to rejig the var pattern because of the linter... 💩 * 🐷 💄 Special debug mode for config - I ❤️ being able to output the config, but this is not useful when trying to debug / optimise timings. - This change makes it so we can see how long it takes to do config work by default - If we want to output config specifically, we do `DEBUG=ghost:*,ghost-config npm start` - This also prevents nconf.get() from being called unnecessarily
This commit is contained in:
parent
29d04fd6a2
commit
9bd50cb527
@ -1,11 +1,13 @@
|
||||
var Nconf = require('nconf'),
|
||||
path = require('path'),
|
||||
debug = require('debug')('ghost:config'),
|
||||
_debug = require('debug'),
|
||||
debug = _debug('ghost:config'),
|
||||
localUtils = require('./utils'),
|
||||
env = process.env.NODE_ENV || 'development',
|
||||
_private = {};
|
||||
|
||||
_private.loadNconf = function loadNconf(options) {
|
||||
debug('config start');
|
||||
options = options || {};
|
||||
|
||||
var baseConfigPath = options.baseConfigPath || __dirname,
|
||||
@ -51,7 +53,13 @@ _private.loadNconf = function loadNconf(options) {
|
||||
*/
|
||||
nconf.set('env', env);
|
||||
|
||||
debug(nconf.get());
|
||||
// Wrap this in a check, because else nconf.get() is executed unnecessarily
|
||||
// To output this, use DEBUG=ghost:*,ghost-config
|
||||
if (_debug.enabled('ghost-config')) {
|
||||
debug(nconf.get());
|
||||
}
|
||||
|
||||
debug('config end');
|
||||
return nconf;
|
||||
};
|
||||
|
||||
|
24
index.js
24
index.js
@ -1,12 +1,21 @@
|
||||
// # Ghost Startup
|
||||
// Orchestrates the startup of Ghost when run from command line.
|
||||
var ghost = require('./core'),
|
||||
debug = require('debug')('ghost:boot:index'),
|
||||
express = require('express'),
|
||||
logging = require('./core/server/logging'),
|
||||
errors = require('./core/server/errors'),
|
||||
utils = require('./core/server/utils'),
|
||||
parentApp = express();
|
||||
console.time('Ghost boot');
|
||||
|
||||
var debug = require('debug')('ghost:boot:index'),
|
||||
ghost, express, logging, errors, utils, parentApp;
|
||||
|
||||
debug('First requires...');
|
||||
|
||||
ghost = require('./core');
|
||||
|
||||
debug('Required ghost');
|
||||
|
||||
express = require('express');
|
||||
logging = require('./core/server/logging');
|
||||
errors = require('./core/server/errors');
|
||||
utils = require('./core/server/utils');
|
||||
parentApp = express();
|
||||
|
||||
debug('Initialising Ghost');
|
||||
ghost().then(function (ghostServer) {
|
||||
@ -16,6 +25,7 @@ ghost().then(function (ghostServer) {
|
||||
debug('Starting Ghost');
|
||||
// Let Ghost handle starting our server instance.
|
||||
return ghostServer.start(parentApp).then(function afterStart() {
|
||||
console.timeEnd('Ghost boot');
|
||||
// if IPC messaging is enabled, ensure ghost sends message to parent
|
||||
// process on successful start
|
||||
if (process.send) {
|
||||
|
Loading…
Reference in New Issue
Block a user