5

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
  • 48,582
  • 42
  • 134
  • 263

2 Answers2

1

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,051
  • 16
  • 83
  • 125
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,673
  • 5
  • 57
  • 77