Remove deprecated restart function

This commit is contained in:
loicsaintroch 2016-03-02 14:40:18 +01:00
parent 485dd3dcf5
commit f681c1be7c
3 changed files with 0 additions and 126 deletions

View File

@ -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')();

View File

@ -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
*

View File

@ -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();
});
});
};