无法将krakenjs +节点站点作为Azure网站运行

时间:2014-10-23 06:51:46

标签: node.js azure iisnode kraken.js

经过一番摆弄后,我让Azure正确地从我的GIT存储库中提取最新信息并运行相应的bower和grunt命令来构建所有内容。这似乎不是问题。

问题是当尝试通过浏览器实际加载我的网站时,IIS失败并出现500.1001错误。试图在本地复制问题,因为我无法弄清楚如何获取任何日志信息,我在我的本地IIS上安装了iisnode,发现我遇到了同样的问题...直到我让我的应用程序池在系统下运行用户帐号。 (我知道,我知道)

不幸的是,如果错误也是某种奇怪的节点权限错误,我不确定在Azure网站环境中该怎么做。我只是在冲洗吗?经过一些麻烦之后,我将一个iisnode.yml文件放入我的FTP中以启用dev错误,我终于得到了某些东西

HRESULT: 0x2
HTTP status: 500
HTTP subStatus: 1001
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 node.exe process has not written any information to stderr or iisnode was unable to capture this information. Frequent reason is that the iisnode module is unable to create a log file to capture stdout and stderr output from node.exe. Please check that the identity of the IIS application pool running the node.js application has read and write access permissions to the directory on the server where the node.js application is located. Alternatively you can disable logging by setting system.webServer/iisnode/@loggingEnabled element of web.config to 'false'.

之后我设法获得了stdout日志:

Application ready to serve requests.
Environment: development

这只是我在本地运行时通常看到的一半。 “服务器正在侦听...”消息永远不会触发,这告诉我它可能只是没有那么远。我现在还不确定还有什么可做的。如果VM是我唯一的选择,我认为我宁愿先看看heroku或nodejitsu,因为我不想真的为那些沉重的东西买单。这是运行应用程序的Krakenjs索引文件。

'use strict';

var http = require('http');
var express = require('express');
var kraken = require('kraken-js');


var options, app, server;
options = {
    onconfig: function (config, next) {
        next(null, config);
    }
};

app = module.exports = express();
app.use(kraken(options));
app.on('start', function () {
    console.log('Application ready to serve requests.');
    console.log('Environment: %s', app.kraken.get('env:env'));
});

if (!module.parent) {

    server = http.createServer(app);
    server.listen(process.env.PORT || 8000);
    server.on('listening', function () {
        console.log('Server listening on http://localhost:%d', this.address().port);
    });

}

更新:添加web.config和iisnode.yml文件

的Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <iisnode node_env="production" />
    <!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->    
    <handlers>
      <!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
      <add name="iisnode" path="index.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
       <rules>
        <rule name="hello">
           <match url="/*" />
          <action type="Rewrite" url="index.js" />
         </rule>
       </rules>
     </rewrite>

    <!-- Make sure error responses are left untouched -->
    <httpErrors existingResponse="PassThrough" />
  </system.webServer>
  <appSettings>
    <add key="PORT" value="80" />
  </appSettings>
</configuration>

和iisnode.yml文件:

node_env: development
loggingEnabled: true
logDirectory: iisnode

maxLogFileSizeInKB: 128
maxTotalLogFileSizeInKB: 1024
maxLogFiles: 20
devErrorsEnabled: true

我知道node_env彼此冲突,据我所知iisnode文件获胜,这就是为什么我设置不同以查看是否有变化的原因。

0 个答案:

没有答案