0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Improved testmode logging of shutdown status

- testmode allows us to test Ghost's behaviour with long running requests and jobs
- moved all the testmode logging to only happen if Ghost starts successfully to make it clearer what is happening
- added a (currently very dirty) bit of code to fetch the jobService and output the queue status giving us a similar
     output for both open connections and jobs
- all of this allows for debugging exactly what Ghost is doing whilst it is processing a shutdown request
This commit is contained in:
Hannah Wolfe 2020-08-18 15:36:21 +01:00
parent cefcdad090
commit 9f291b2d10

View file

@ -107,6 +107,26 @@ class GhostServer {
debug('...Started');
self._logStartMessages();
// Debug logs output in testmode only
if (config.get('server:testmode')) {
// This is horrible and very temporary
const jobService = require('./services/jobs');
// Output how many connections are open every 5 seconds
const connectionInterval = setInterval(() => self.httpServer.getConnections(
(err, connections) => logging.warn(`${connections} connections currently open`)
), 5000);
// Output a notice when the server closes
self.httpServer.on('close', function () {
clearInterval(connectionInterval);
logging.warn('Server has fully closed');
});
// Output job queue length every 5 seconds
setInterval(() => logging.warn(`${jobService.queue.length()} jobs in the queue. Idle: ${jobService.queue.idle()}`), 5000);
}
return GhostServer.announceServerReadiness()
.finally(() => {
resolve(self);
@ -119,13 +139,6 @@ class GhostServer {
process
.removeAllListeners('SIGINT').on('SIGINT', self.shutdown.bind(self))
.removeAllListeners('SIGTERM').on('SIGTERM', self.shutdown.bind(self));
if (config.get('server:testmode')) {
// Debug code
setInterval(() => self.httpServer.getConnections(
(err, connections) => logging.warn(`${connections} connections currently open`)
), 5000);
}
});
}