Skip to content

Commit 7d765c4

Browse files
tapasthakkarkeyurkarnik
authored andcommitted
190715670 Fix the issue of requests getting stuck on reload
Add prior notice to worker process before disconnect Updated all the references of memored to emgCache
1 parent 02a8539 commit 7d765c4

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

cli/lib/reload-cluster.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var cluster = require('cluster');
44
var EventEmitter = require('events').EventEmitter;
55
var cpuCount = require('os').cpus().length;
6-
const cache = require('microgateway-plugins').memored;
6+
const cache = require('microgateway-plugins').emgCache;
77
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
88

99
const CONSOLE_LOG_TAG_COMP = 'microgateway reload cluster';
@@ -153,8 +153,14 @@ function cullProcesses() {
153153
//
154154
if ( !(w.isDead()) && w.isConnected() ) { // If the processes is still live .. first disconnect it
155155
try {
156-
w.disconnect() // from the IPC
157-
w_info.request_disconnect = true
156+
if(w_info.request_disconnect) {
157+
w.disconnect(); // from the IPC
158+
}
159+
else {
160+
w_info.request_disconnect = true;
161+
w.send({ request_disconnect: true });
162+
console.log(`[${w.process.pid}] sending disconnect request signal to worker`);
163+
}
158164
} catch (e) {
159165
// might have never connected
160166
//writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},e)
@@ -286,7 +292,7 @@ class ClusterManager extends EventEmitter {
286292

287293
// --initializeCache---------------------------------------
288294
initializeCache() {
289-
//setup memored - a cache shared between worker processes. intro in 2.5.9
295+
// setup emgCache (wrapper above memored) - a cache shared between worker processes. intro in 3.2.3
290296
cache.setup({
291297
purgeInterval: PURGE_INTERVAL
292298
});

test-stress/reload-cluster-old.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var cluster = require('cluster');
44
var EventEmitter = require('events').EventEmitter;
55
var cpuCount = require('os').cpus().length;
6-
const cache = require('microgateway-plugins').memored;
6+
const cache = require('microgateway-plugins').emgCache;
77

88
const PURGE_INTERVAL = 60000;
99

@@ -189,7 +189,7 @@ var ReloadCluster = (file, opt) => {
189189
*/
190190
self.run = () => {
191191
if (!cluster.isMaster) return;
192-
//setup memored - a cache shared between worker processes. intro in 2.5.9
192+
// setup emgCache (wrapper above memored) - a cache shared between worker processes. intro in 3.2.3
193193
cache.setup({
194194
purgeInterval: PURGE_INTERVAL
195195
});

0 commit comments

Comments
 (0)