- Version: *
- Platform: *
- Subsystem: cluster
When worker event loop is blocked, it can not disconnect from the master. So the proc.kill will not be executed.
The SIGTERM can not work is good for me. I wish SIGKILL will work in this scenario as the doc.
'SIGKILL' cannot have a listener installed, it will unconditionally terminate Node.js on all platforms.
And here is the code.
'use strict';
const cluster = require('cluster');
const assert = require('assert');
const isMaster = cluster.isMaster;
if (isMaster) {
const worker = cluster.fork();
setTimeout(() => {
worker.kill('SIGKILL'); // worker.process.kill('SIGKILL');
}, 1000);
worker.on('exit', () => {
console.log('worker exit');
})
} else {
let i = 2;
while(true) {
i = i % 2;
}
}
worker.process.kill works, but looks like odd.
When worker event loop is blocked, it can not disconnect from the master. So the
proc.killwill not be executed.The
SIGTERMcan not work is good for me. I wishSIGKILLwill work in this scenario as the doc.And here is the code.
worker.process.killworks, but looks like odd.