mirror of
https://github.com/strapi/strapi.git
synced 2025-11-15 09:39:15 +00:00
Fix cluster strapi.stop
This commit is contained in:
parent
d855d99fd1
commit
54c7f03c31
@ -73,7 +73,9 @@ module.exports = function() {
|
|||||||
setFilesToWatch(process.cwd());
|
setFilesToWatch(process.cwd());
|
||||||
|
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
cluster.on('message', () => {
|
cluster.on('message', (worker, message) => {
|
||||||
|
if (message !== 'reload') return;
|
||||||
|
|
||||||
strapi.log.info('The server is restarting\n');
|
strapi.log.info('The server is restarting\n');
|
||||||
|
|
||||||
_.forEach(cluster.workers, worker => worker.kill());
|
_.forEach(cluster.workers, worker => worker.kill());
|
||||||
@ -81,6 +83,14 @@ module.exports = function() {
|
|||||||
cluster.fork();
|
cluster.fork();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cluster.on('message', (worker, message) => {
|
||||||
|
if (message !== 'stop') return;
|
||||||
|
|
||||||
|
_.forEach(cluster.workers, worker => worker.kill());
|
||||||
|
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
cluster.fork();
|
cluster.fork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -137,6 +137,9 @@ class Strapi extends EventEmitter {
|
|||||||
stop() {
|
stop() {
|
||||||
// Destroy server and available connections.
|
// Destroy server and available connections.
|
||||||
this.server.destroy();
|
this.server.destroy();
|
||||||
|
|
||||||
|
if (cluster.isWorker && process.env.NODE_ENV === 'development' && this.config.currentEnvironment.server.autoReload === true) process.send('stop');
|
||||||
|
|
||||||
// Kill process.
|
// Kill process.
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
@ -162,7 +165,7 @@ class Strapi extends EventEmitter {
|
|||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
const reload = function() {
|
const reload = function() {
|
||||||
if (cluster.isWorker && process.env.NODE_ENV === 'development' && this.config.currentEnvironment.server.autoReload === true) process.send('message');
|
if (cluster.isWorker && process.env.NODE_ENV === 'development' && this.config.currentEnvironment.server.autoReload === true) process.send('reload');
|
||||||
};
|
};
|
||||||
|
|
||||||
reload.isReloading = false;
|
reload.isReloading = false;
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
module.exports = function reload() {
|
module.exports = function reload() {
|
||||||
try {
|
try {
|
||||||
const reload = function() {
|
const reload = function() {
|
||||||
if (cluster.isWorker && process.env.NODE_ENV === 'development' && this.config.environments[this.config.environment].server.reload === true) process.send('message');
|
if (cluster.isWorker && process.env.NODE_ENV === 'development' && this.config.environments[this.config.environment].server.reload === true) process.send('reload');
|
||||||
};
|
};
|
||||||
|
|
||||||
reload.isReloading = false;
|
reload.isReloading = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user