close chidl processes when parent exits

This commit is contained in:
Jan Prochazka
2020-05-01 09:35:57 +02:00
parent 17134552ce
commit 933f29afda
9 changed files with 39 additions and 4 deletions

View File

@@ -27,7 +27,12 @@ module.exports = {
},
test(req, res) {
const subprocess = fork(process.argv[1], ['connectProcess']);
subprocess.on('message', (resp) => res.json(resp));
subprocess.on('message', (resp) => {
const { msgtype } = res;
if (msgtype == 'connected' || msgtype == 'error') {
res.json(resp);
}
});
subprocess.send(req.body);
},