7

Is it possible to run a function as a completely separate node.js process? For example:

var parallel = require("parallel");
parallel(function(){
    var app = require("express")();
    app.on("/",function(req,res){ res.send("hi"); });
    app.listen(80);
},function callback(err,stdout){
    console.log("process terminated!")
});

Is something like that possible?

MaiaVictor
  • 51,090
  • 44
  • 144
  • 286

2 Answers2

2

First off, try to use the idiomatic way of load-balancing. For node, this is asynchronous design. See these other answers for more info:

There are options though:

Community
  • 1
  • 1
beatgammit
  • 19,817
  • 19
  • 86
  • 129
0

Based on node.js on multi-core machines and Dave Dopson's answer

Basically you can run multiple processes and let them communicate with each other.

Community
  • 1
  • 1
Eli
  • 14,779
  • 5
  • 59
  • 77