Use more subprocesses

This commit is contained in:
yflory
2020-03-17 14:18:41 +01:00
parent 0d636dabc9
commit fb0eb1b20c
2 changed files with 33 additions and 5 deletions

View File

@@ -1,8 +1,13 @@
const Nacl = require('tweetnacl/nacl-fast');
// XXX npm "os" and "child_process"
// TODO if this process is using too much CPU, we can use "cluster" to add load balancing to this code
console.log('New child process', process.pid);
process.on('message', function (data) {
console.log('In process', process.pid)
console.log(+new Date(), "Message received by subprocess");
if (!data || !data.key || !data.msg || !data.txid) {
process.send({