Azure上的Node.js集群:ENOTSUP - 无法写入IPC通道

时间:2015-02-19 15:04:38

标签: node.js azure express

是否可以在Azure网站中使用Node.js cluster module

尝试使用群集时出现以下错误:

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)

我的代码:

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'));
    });

}

1 个答案:

答案 0 :(得分:3)

我理解这个问题很久以前就被问过,但自2015年2月以来没有任何变化.Azure网站仍使用IISNode运行nodejs应用程序,而IISNode根本不支持集群。