Display log when application has really restarted

This commit is contained in:
Aurélien Georget 2015-11-23 17:36:59 +01:00
parent 5d7eda0f14
commit aef83536f1
2 changed files with 18 additions and 5 deletions

View File

@ -142,6 +142,9 @@ module.exports = function (strapi) {
// zero downtime reloads.
if (_.isPlainObject(strapi.config.reload) && !_.isEmpty(strapi.config.reload) && strapi.config.reload.workers > 0) {
herd(strapi.config.name)
.close(function () {
process.send('message');
})
.timeout(strapi.config.reload.timeout)
.size(strapi.config.reload.workers)
.run(function () {

View File

@ -57,6 +57,9 @@ module.exports = function (cb) {
// (might be used by some hooks).
self.reloading = true;
self.log.warn('Application is restarting...');
console.log();
// Teardown Waterline adapters and
// reload the Waterline ORM.
self.after('hook:waterline:reloaded', function () {
@ -75,15 +78,22 @@ module.exports = function (cb) {
self.log.warn('You still need to restart your server to fully enjoy changes...');
}
self.once('restart:done', function () {
strapi.log.info('Application successfully restarted');
});
if (cluster.isMaster) {
_.forEach(cluster.workers, function (worker) {
worker.on('message', function () {
self.emit('restart:done');
});
});
}
// Kill every worker processes.
_.forEach(cluster.workers, function () {
process.kill(process.pid, 'SIGHUP');
});
if (cluster.isMaster && _.isPlainObject(strapi.config.reload) && !_.isEmpty(strapi.config.reload) && strapi.config.reload.workers > 0) {
self.log.info('Application restarted');
console.log();
}
});
// Reloading the router.