jeudi 19 février 2015

Node.js cluster on Azure: ENOTSUP - cannot write to IPC channel

Is it possible to use Node.js cluster module in Azure Web Sites?


I got the following error trying to use the cluster:



Thu Feb 19 2015 14:54:56 GMT+0000 (Coordinated Universal Time): Unaught exception: Error: write ENOTSUP - cannot write to IPC channel.
at errnoException (child_process.js:1001:11)
at ChildProcess.target.send (child_process.js:465:16)
at Worker.send (cluster.js:406:21)
at sendInternalMessage (cluster.js:399:10)
at handleResponse (cluster.js:177:5)
at respond (cluster.js:192:5)
at Object.messageHandler.queryServer (cluster.js:247:5)
at handleMessage (cluster.js:197:32)
at ChildProcess.emit (events.js:117:20)
at handleMessage (child_process.js:322:10)


My code:



var PORT = process.env.PORT || 3000;
var express = require('express');
var routes = require('./routes');
var http = require('http');
var path = require('path');

var app = express();


app.set('port', PORT);
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(require('express-domain-middleware'));
app.use(app.router);
app.use(express.bodyParser());
app.use(express.static(path.join(__dirname, 'public')));

var server = http.createServer(app);

app.use(function errorHandler(err, req, res, next) {
console.log('error on request %d %s %s: %j', process.domain.id, req.method, req.url, err.message);
res.send(500, "Something bad happened. :(");
});

app.get('/', routes.index);


var cluster = require('cluster');

if (cluster.isMaster) {
for (var i = 0; i < 1; i++) {
cluster.fork();
}

cluster.on('death', function(worker) {
cluster.log('worker ' + worker.pid + ' died');
});
} else {
server.listen(app.get('port'), function() {
console.log('Express server listening on port ' + app.get('port'));
});

}

Aucun commentaire:

Enregistrer un commentaire