mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05: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
2 changed files with 27 additions and 9 deletions
|
@ -1,11 +1,13 @@
|
||||||
var Nconf = require('nconf'),
|
var Nconf = require('nconf'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
debug = require('debug')('ghost:config'),
|
_debug = require('debug'),
|
||||||
|
debug = _debug('ghost:config'),
|
||||||
localUtils = require('./utils'),
|
localUtils = require('./utils'),
|
||||||
env = process.env.NODE_ENV || 'development',
|
env = process.env.NODE_ENV || 'development',
|
||||||
_private = {};
|
_private = {};
|
||||||
|
|
||||||
_private.loadNconf = function loadNconf(options) {
|
_private.loadNconf = function loadNconf(options) {
|
||||||
|
debug('config start');
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var baseConfigPath = options.baseConfigPath || __dirname,
|
var baseConfigPath = options.baseConfigPath || __dirname,
|
||||||
|
@ -51,7 +53,13 @@ _private.loadNconf = function loadNconf(options) {
|
||||||
*/
|
*/
|
||||||
nconf.set('env', env);
|
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;
|
return nconf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
24
index.js
24
index.js
|
@ -1,12 +1,21 @@
|
||||||
// # Ghost Startup
|
// # Ghost Startup
|
||||||
// Orchestrates the startup of Ghost when run from command line.
|
// Orchestrates the startup of Ghost when run from command line.
|
||||||
var ghost = require('./core'),
|
console.time('Ghost boot');
|
||||||
debug = require('debug')('ghost:boot:index'),
|
|
||||||
express = require('express'),
|
var debug = require('debug')('ghost:boot:index'),
|
||||||
logging = require('./core/server/logging'),
|
ghost, express, logging, errors, utils, parentApp;
|
||||||
errors = require('./core/server/errors'),
|
|
||||||
utils = require('./core/server/utils'),
|
debug('First requires...');
|
||||||
parentApp = express();
|
|
||||||
|
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');
|
debug('Initialising Ghost');
|
||||||
ghost().then(function (ghostServer) {
|
ghost().then(function (ghostServer) {
|
||||||
|
@ -16,6 +25,7 @@ ghost().then(function (ghostServer) {
|
||||||
debug('Starting Ghost');
|
debug('Starting Ghost');
|
||||||
// Let Ghost handle starting our server instance.
|
// Let Ghost handle starting our server instance.
|
||||||
return ghostServer.start(parentApp).then(function afterStart() {
|
return ghostServer.start(parentApp).then(function afterStart() {
|
||||||
|
console.timeEnd('Ghost boot');
|
||||||
// if IPC messaging is enabled, ensure ghost sends message to parent
|
// if IPC messaging is enabled, ensure ghost sends message to parent
|
||||||
// process on successful start
|
// process on successful start
|
||||||
if (process.send) {
|
if (process.send) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue