I am experimenting with Node.js and regardless of whether it is worth offering in my company. Being new to this, I am trying to get a Node descriptor without Express (or an alternative so far), and the fact that an unhandled exception causes the whole process to stop and basically gets me off the network seems like a problem. He very clearly says not to use an uncaught exception handler for the process of swallowing errors.
The Node.js module of the cluster seems to work fine if I combine it with domains . In fact, domains recommend using them only for sending 500 and using clusters so that you can actually terminate the process with an error.
I am running Windows 8 Enterprise x64 and have installed Node.js for my OS / architecture using msi. Node.js works for me and play with it. However, when I run the sample code from the cluster module tutorial and then try to click http://localhost:8000, my browser will not be able to connect. If I put a call console.log()in an else block, it also never hits.
Here is the code I'm using:
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
cluster.settings = {
execArgv: process.execArgv,
exec: process.argv[1],
args: process.argv.slice(2),
silent: false
};
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
} else {
console.log("This never hits.");
http.createServer(function(req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8000);
}
Can I fix this on Windows 8 Enterprise x64? Is there any explanation why it is not working?