mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Cleaned up global server events
- use theme.ready for loading themes instead of server.start and properly clean this up - remove server.start and server.stop as they are no longer used (only server.start was used, and only for themes) - we're moving away from the pattern of using global events like this as they are hard to reason about
This commit is contained in:
parent
d150516ec3
commit
b1a98b0b67
@ -28,10 +28,6 @@ module.exports = {
|
||||
themeLoader.loadAllThemes();
|
||||
});
|
||||
|
||||
events.on('themes.ready', function readAllThemesOnServerStart() {
|
||||
themeLoader.loadAllThemes();
|
||||
});
|
||||
|
||||
// Just read the active theme for now
|
||||
return themeLoader
|
||||
.loadOneTheme(activeThemeName)
|
||||
|
@ -9,7 +9,7 @@ const _ = require('lodash');
|
||||
const config = require('../shared/config');
|
||||
const urlUtils = require('./../shared/url-utils');
|
||||
const errors = require('@tryghost/errors');
|
||||
const {events, i18n} = require('./lib/common');
|
||||
const {i18n} = require('./lib/common');
|
||||
const logging = require('../shared/logging');
|
||||
const moment = require('moment');
|
||||
const bootstrapSocket = require('@tryghost/bootstrap-socket');
|
||||
@ -162,7 +162,6 @@ class GhostServer {
|
||||
await this._cleanup();
|
||||
} finally {
|
||||
// Wrap up
|
||||
events.emit('server.stop');
|
||||
this.httpServer = null;
|
||||
this._logStopMessages();
|
||||
}
|
||||
@ -326,9 +325,6 @@ module.exports.announceServerReadiness = function (error = null) {
|
||||
if (error) {
|
||||
message.started = false;
|
||||
message.error = error;
|
||||
} else {
|
||||
debug('emit: server.start');
|
||||
events.emit('server.start');
|
||||
}
|
||||
|
||||
// CASE: IPC communication to the CLI for local process manager
|
||||
|
@ -102,18 +102,5 @@ describe('GhostServer', function () {
|
||||
process.send.calledOnce.should.be.true();
|
||||
socketStub.calledOnce.should.be.true();
|
||||
});
|
||||
|
||||
it('sends server.start event correctly on success', function () {
|
||||
GhostServer.announceServerReadiness();
|
||||
|
||||
eventSpy.calledOnce.should.be.true();
|
||||
eventSpy.firstCall.args[0].should.eql('server.start');
|
||||
});
|
||||
|
||||
it('does not send server.start event on failure', function () {
|
||||
GhostServer.announceServerReadiness(new Error('something went wrong'));
|
||||
|
||||
eventSpy.calledOnce.should.be.false();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -209,8 +209,8 @@ const restartModeGhostStart = async () => {
|
||||
// @TODO: why does this happen _after_ URL service
|
||||
web.shared.middlewares.customRedirects.reload();
|
||||
|
||||
// Trigger server start, which is ONLY used for theme reload
|
||||
events.emit('server.start');
|
||||
// Trigger themes to load again
|
||||
events.emit('themes.ready');
|
||||
};
|
||||
|
||||
const bootGhost = async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user