mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-25 02:31:59 -05:00
🎨 replace config.getSocket()
refs #6982 - was a function in ConfigManager - does belong to the GhostServer logic [ci skip]
This commit is contained in:
parent
f4bee50e86
commit
d42f4f6058
1 changed files with 21 additions and 8 deletions
|
@ -3,6 +3,8 @@
|
||||||
var Promise = require('bluebird'),
|
var Promise = require('bluebird'),
|
||||||
chalk = require('chalk'),
|
chalk = require('chalk'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
|
path = require('path'),
|
||||||
|
_ = require('lodash'),
|
||||||
errors = require('./errors'),
|
errors = require('./errors'),
|
||||||
config = require('./config'),
|
config = require('./config'),
|
||||||
i18n = require('./i18n'),
|
i18n = require('./i18n'),
|
||||||
|
@ -35,22 +37,33 @@ function GhostServer(rootApp) {
|
||||||
*/
|
*/
|
||||||
GhostServer.prototype.start = function (externalApp) {
|
GhostServer.prototype.start = function (externalApp) {
|
||||||
var self = this,
|
var self = this,
|
||||||
rootApp = externalApp ? externalApp : self.rootApp;
|
rootApp = externalApp ? externalApp : self.rootApp,
|
||||||
|
socketConfig, socketValues = {
|
||||||
|
path: path.join(config.get('paths').contentPath, process.env.NODE_ENV + '.socket'),
|
||||||
|
permissions: '660'
|
||||||
|
};
|
||||||
|
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
var socketConfig = config.getSocket();
|
if (config.get('server').hasOwnProperty('socket')) {
|
||||||
|
socketConfig = config.get('server').socket;
|
||||||
|
|
||||||
|
if (_.isString(socketConfig)) {
|
||||||
|
socketValues.path = socketConfig;
|
||||||
|
} else if (_.isObject(socketConfig)) {
|
||||||
|
socketValues.path = socketConfig.path || socketValues.path;
|
||||||
|
socketValues.permissions = socketConfig.permissions || socketValues.permissions;
|
||||||
|
}
|
||||||
|
|
||||||
if (socketConfig) {
|
|
||||||
// Make sure the socket is gone before trying to create another
|
// Make sure the socket is gone before trying to create another
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(socketConfig.path);
|
fs.unlinkSync(socketValues.path);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// We can ignore this.
|
// We can ignore this.
|
||||||
}
|
}
|
||||||
|
|
||||||
self.httpServer = rootApp.listen(socketConfig.path);
|
self.httpServer = rootApp.listen(socketValues.path);
|
||||||
|
fs.chmod(socketValues.path, socketValues.permissions);
|
||||||
fs.chmod(socketConfig.path, socketConfig.permissions);
|
config.set('server:socket', socketValues);
|
||||||
} else {
|
} else {
|
||||||
self.httpServer = rootApp.listen(
|
self.httpServer = rootApp.listen(
|
||||||
config.get('server').port,
|
config.get('server').port,
|
||||||
|
@ -176,7 +189,7 @@ GhostServer.prototype.logStartMessages = function () {
|
||||||
console.log(
|
console.log(
|
||||||
chalk.green(i18n.t('notices.httpServer.ghostIsRunningIn', {env: process.env.NODE_ENV})),
|
chalk.green(i18n.t('notices.httpServer.ghostIsRunningIn', {env: process.env.NODE_ENV})),
|
||||||
i18n.t('notices.httpServer.listeningOn'),
|
i18n.t('notices.httpServer.listeningOn'),
|
||||||
config.getSocket() || config.get('server').host + ':' + config.get('server').port,
|
config.get('server').socket || config.get('server').host + ':' + config.get('server').port,
|
||||||
i18n.t('notices.httpServer.urlConfiguredAs', {url: config.get('url')}),
|
i18n.t('notices.httpServer.urlConfiguredAs', {url: config.get('url')}),
|
||||||
chalk.gray(i18n.t('notices.httpServer.ctrlCToShutDown'))
|
chalk.gray(i18n.t('notices.httpServer.ctrlCToShutDown'))
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue