forked from TryGhost/Ghost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (37 loc) · 1.33 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// # Ghost Startup
// Orchestrates the startup of Ghost when run from command line.
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) {
// Mount our Ghost instance on our desired subdirectory path if it exists.
parentApp.use(utils.url.getSubdir(), ghostServer.rootApp);
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) {
process.send({started: true});
}
});
}).catch(function (err) {
if (!errors.utils.isIgnitionError(err)) {
err = new errors.GhostError({err: err});
}
if (process.send) {
process.send({started: false, error: err.message});
}
logging.error(err);
process.exit(-1);
});