diff --git a/lib/Strapi.js b/lib/Strapi.js index 339f5a63d8..28e370e4e1 100755 --- a/lib/Strapi.js +++ b/lib/Strapi.js @@ -40,7 +40,6 @@ function Strapi() { this.load = this.load.bind(this); this.start = this.start.bind(this); this.stop = this.stop.bind(this); - this.restart = this.restart.bind(this); this.initialize = this.initialize.bind(this); this.exposeGlobals = this.exposeGlobals.bind(this); this.runBootstrap = this.runBootstrap.bind(this); @@ -80,7 +79,6 @@ util.inherits(Strapi, events.EventEmitter); Strapi.prototype.start = require('./start'); Strapi.prototype.stop = require('./stop'); -Strapi.prototype.restart = require('./restart'); Strapi.prototype.server = require('koa'); Strapi.prototype.app = require('koa')(); diff --git a/lib/configuration/hooks/studio/index.js b/lib/configuration/hooks/studio/index.js index f5edfc7b39..d8c5a1585d 100644 --- a/lib/configuration/hooks/studio/index.js +++ b/lib/configuration/hooks/studio/index.js @@ -368,22 +368,6 @@ module.exports = function (strapi) { }); }, - /** - * Rebuild dictionary - * - * @param {Object} data - * - * @return {Function} cb - */ - - rebuild: function (data, cb) { - process.nextTick(function () { - strapi.restart(function () { - cb(null, true); - }); - }); - }, - /** * Remove file or folder * diff --git a/lib/restart.js b/lib/restart.js deleted file mode 100644 index 2ee52de9dd..0000000000 --- a/lib/restart.js +++ /dev/null @@ -1,108 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const cluster = require('cluster'); - -// Public node modules. -const _ = require('lodash'); -const async = require('async'); - -/** - * Programmatically restart the server - * (useful for the Studio) - */ - -module.exports = cb => { - console.log(); - - // Update the Strapi status (might be used - // by the core or some hooks). - strapi.reloading = true; - - // Async module loader to rebuild a - // dictionary of the application. - async.auto({ - - // Rebuild the dictionaries. - dictionaries: cb => { - strapi.on('hook:_config:reloaded', () => { - strapi.on('hook:_api:reloaded', () => cb()); - strapi.hooks._api.reload(); - }); - - strapi.hooks._config.reload(); - } - }, - - // Callback. - err => { - let count = 0; - - // Just in case there is an error. - if (err) { - strapi.log.error('Impossible to reload the server'); - strapi.log.error('Please restart the server manually'); - strapi.stop(); - } - - // Tell the application the framework is reloading - // (might be used by some hooks). - strapi.reloading = true; - - // Run adapters installation - if (cluster.isMaster) { - - ++count; - - if (_.isPlainObject(strapi.config.views) && !_.isBoolean(strapi.config.views)) { - strapi.hooks.views.installation(); - - ++count; - } - } - - const installed = _.after(count, () => { - if (_.isPlainObject(strapi.config.reload) && !_.isEmpty(strapi.config.reload) && strapi.config.reload.workers > 0) { - strapi.log.warn('Application is restarting...'); - console.log(); - } - - // Reload the router. - strapi.after('hook:router:reloaded', () => { - process.nextTick(() => cb()); - - // Update `strapi` status. - strapi.reloaded = true; - strapi.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) { - strapi.log.info('Application\'s dictionnary updated'); - strapi.log.warn('You still need to restart your server to fully enjoy changes...'); - } - - strapi.once('restart:done', function () { - strapi.log.info('Application successfully restarted'); - }); - - if (cluster.isMaster) { - _.forEach(cluster.workers, worker => worker.on('message', () => strapi.emit('restart:done'))); - } - - // Kill every worker processes. - _.forEach(cluster.workers, () => process.kill(process.pid, 'SIGHUP')); - }); - - // Reloading the router. - strapi.hooks.router.reload(); - }); - - strapi.after('hook:views:installed', () => { - installed(); - }); - }); -};