mirror of
https://github.com/strapi/strapi.git
synced 2025-09-03 05:39:36 +00:00
Fix restart #42
This commit is contained in:
parent
859995ec6a
commit
0851c056d8
@ -17,7 +17,7 @@ const __initializeHooks = require('./private/loadHooks');
|
||||
* Load the Strapi instance
|
||||
*/
|
||||
|
||||
module.exports = (strapi) => {
|
||||
module.exports = strapi => {
|
||||
const Configuration = __Configuration(strapi);
|
||||
const initializeHooks = __initializeHooks(strapi);
|
||||
|
||||
|
@ -16,7 +16,8 @@ const async = require('async');
|
||||
* (useful for the Studio)
|
||||
*/
|
||||
|
||||
module.exports = (cb) => {
|
||||
module.exports = cb => {
|
||||
const self = this;
|
||||
|
||||
console.log();
|
||||
|
||||
@ -30,12 +31,12 @@ module.exports = (cb) => {
|
||||
|
||||
// Rebuild the dictionaries.
|
||||
dictionaries: cb => {
|
||||
this.on('hook:_config:reloaded', () => {
|
||||
this.on('hook:_api:reloaded', () => cb());
|
||||
this.hooks._api.reload();
|
||||
self.on('hook:_config:reloaded', () => {
|
||||
self.on('hook:_api:reloaded', () => cb());
|
||||
self.hooks._api.reload();
|
||||
});
|
||||
|
||||
this.hooks._config.reload();
|
||||
self.hooks._config.reload();
|
||||
}
|
||||
},
|
||||
|
||||
@ -44,47 +45,47 @@ module.exports = (cb) => {
|
||||
|
||||
// Just in case there is an error.
|
||||
if (err) {
|
||||
this.log.error('Impossible to reload the server');
|
||||
this.log.error('Please restart the server manually');
|
||||
this.stop();
|
||||
self.log.error('Impossible to reload the server');
|
||||
self.log.error('Please restart the server manually');
|
||||
self.stop();
|
||||
}
|
||||
|
||||
// Tell the application the framework is reloading
|
||||
// (might be used by some hooks).
|
||||
this.reloading = true;
|
||||
self.reloading = true;
|
||||
|
||||
// Run adapters installation
|
||||
if (cluster.isMaster) {
|
||||
this.hooks.waterline.installation();
|
||||
self.hooks.waterline.installation();
|
||||
}
|
||||
|
||||
// Install new adapters
|
||||
strapi.after('hook:waterline:installed', () => {
|
||||
this.log.warn('Application is restarting...');
|
||||
self.log.warn('Application is restarting...');
|
||||
console.log();
|
||||
|
||||
// Teardown Waterline adapters and
|
||||
// reload the Waterline ORM.
|
||||
this.after('hook:waterline:reloaded', () => {
|
||||
this.after('hook:router:reloaded', () => {
|
||||
self.after('hook:waterline:reloaded', () => {
|
||||
self.after('hook:router:reloaded', () => {
|
||||
process.nextTick(() => cb());
|
||||
|
||||
// Update `strapi` status.
|
||||
this.reloaded = true;
|
||||
this.reloading = false;
|
||||
self.reloaded = true;
|
||||
self.reloading = false;
|
||||
|
||||
// Finally inform the developer everything seems ok.
|
||||
if (cluster.isMaster && _.isPlainObject(strapi.config.reload) && !_.isEmpty(strapi.config.reload) && strapi.config.reload.workers < 1) {
|
||||
this.log.info('Application\'s dictionnary updated');
|
||||
this.log.warn('You still need to restart your server to fully enjoy changes...');
|
||||
self.log.info('Application\'s dictionnary updated');
|
||||
self.log.warn('You still need to restart your server to fully enjoy changes...');
|
||||
}
|
||||
|
||||
this.once('restart:done', function () {
|
||||
self.once('restart:done', function () {
|
||||
strapi.log.info('Application successfully restarted');
|
||||
});
|
||||
|
||||
if (cluster.isMaster) {
|
||||
_.forEach(cluster.workers, (worker) => worker.on('message', () => self.emit('restart:done')));
|
||||
_.forEach(cluster.workers, worker => worker.on('message', () => self.emit('restart:done')));
|
||||
}
|
||||
|
||||
// Kill every worker processes.
|
||||
@ -92,11 +93,11 @@ module.exports = (cb) => {
|
||||
});
|
||||
|
||||
// Reloading the router.
|
||||
this.hooks.router.reload();
|
||||
self.hooks.router.reload();
|
||||
});
|
||||
|
||||
// Reloading the ORM.
|
||||
this.hooks.waterline.reload();
|
||||
self.hooks.waterline.reload();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user