stream.on('end', () => { app.send('finish'); });
function addRun(){ var aic = child_process.fork("wsserver/ai.js"); aic.on('message', aicMessage); var obj = { pid: aic.pid, aic: aic, name: namelist[ Math.floor(Math.random() * namelist.length)], } aic.send("n" + obj.name); console.log("aia", obj.pid); clist.push(obj); }
async function run() { console.log('It\'d take a while! If you wanna see logs try DEBUG=app* on package.json!') const files = [f1, f2, f3] for (file of files) { const process = cp.fork(moduleName, []) process.send({ file, header, amout: AMOUNT_ITEMS }); process.on('message', msg => debug(msg)) } }
send(message, callback) { if (this.messageQueue) { this.messageQueue.push([message, callback]); return false; } return this.process.send(message, callback); }
child.on('message', msg => { if (msg.type == 'wrapper_loaded') { child.send({ type: 'init', options: this._options }); } if (msg.type == 'error') throw new Error(msg.error); });
app.get("/", function(req, res) { var child = cp.fork("./child.js"); console.time("hello"); child.on("message", function(i) { // Receive results from child process console.log("received sum is: " + i); }); // Send child process some work child.send("Add 1000 numbers ------- Msg from parent to child"); // Parent console.log("Parent going to end "); res.json("Review your console"); });
server.listen(0, () => { client.send(['connect', server.address().port]); });
ipcMain.once('start-pulling-osu-state', event => { const osuIsRunningChecker = fork(join(__dirname, './processes/osuIsRunning.js')); osuIsRunningChecker.on('message', msg => { event.reply('osu-is-running', !!msg); }); osuIsRunningChecker.send('start'); });
stream.on('data', (chunk) => { const [id, language] = chunk.split(' '); app.send({ id, language }); });
setTimeout(() => { child.send('I am father process. PID: ' + process.pid); }, 2000);
setTimeout(() => { child.send('I will kill you, son! 2 seconds later.'); }, 4000);
rl.on('line', (line) => { child.send(line); });
rl.on('line', (line) => { child.send(line); });