windows server 2012 上部署nodejs,cluster不工作,有没有同学碰到过这种情况?
发布于 9 年前 作者 patrickgao 5780 次浏览 最后一次编辑是 8 年前 来自 问答

使用如下代码:

if (cluster.isMaster) {
    // Fork启一个Worker 进程
    for (var i = 0; i < numCPUs; i++) {
        cluster.fork();
    }

    cluster.on('listening', (worker, address) => {
        console.log('worker ' + worker.process.pid + ', listen: ' + address.address + ":" + address.port);
    });

    cluster.on('exit', (worker, code, signal) => {
        console.log('worker ' + worker.process.pid + ' died');
        //重启一个worker进程
        cluster.fork();
    });
} else {
    // Worker 进程之间可以共享任何形式的TCP连接
    // 也可以启动一个express的web服务
    var server = app.listen(app.get('port'), function() {
        debug('Express server listening on port ' + server.address().port);
    });
}


系统报错:

isnode encountered an error when processing the request.

HRESULT: 0x2 HTTP status: 500 HTTP subStatus: 1002 HTTP reason: Internal Server Error

You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is ‘true’.

In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.

The last 64k of the output generated by the node.exe process to stderr is shown below:

Application has thrown an uncaught exception and is terminated: Error: write ENOTSUP at exports._errnoException (util.js:870:11) at ChildProcess.target._send (internal/child_process.js:611:20) at ChildProcess.target.send (internal/child_process.js:507:12) at sendHelper (cluster.js:723:8) at send (cluster.js:518:5) at cluster.js:493:7 at SharedHandle.options.process.on.process.on.SharedHandle.add (cluster.js:86:3) at queryServer (cluster.js:485:12) at Worker.onmessage (cluster.js:433:7) at ChildProcess.<anonymous> (cluster.js:737:8)

把 cluster 部份的代码注释掉后,一切正常。有没有同学碰到过,是如何解决这类问题的?

6 回复

换成ubuntu或者其它linux服务器吧,

不行啊,要和.net的程序配合。好在我在iisnode上找到了这个问题的解决方法,也不知道对不对。

<iisnode watchedFiles="*.js;node_modules*;routes*.js;views*.html" nodeProcessCountPerApplication=“8" nodeProcessCommandLine=”\program files\nodejs\node.exe"/>

我也碰到这个问题,是把cluster去掉,然后配置iisnode吗

我在windows server 上tskill 其中一个node进程 然后tasklist 查看,发现node进程并没有自动重启,数量永久少了一,23333

我就是把cluster去掉,然后配置iisnode的,一样也有这个问题。不知道能不能用forever。有没有知道怎么配置的同学?

QQ截图20160503175248.png

修改这个,即使tskill掉一个进程,当网站被访问时,仍然会自动重启。Start Mode

回到顶部