【问题标题】:Leveraging MultiCore App Service Plan (Windows) for NodeJs in Azure App Service在 Azure 应用服务中利用 NodeJ 的多核应用服务计划 (Windows)
【发布时间】:2018-10-30 10:46:14
【问题描述】:

我创建了一个 nodeJs 应用程序,并已使用 Azure Devops (VSTS) 将其部署到 Azure AppService
我必须指定 Web.config 来运行我的节点应用程序(否则 Azure AppService 应用程序不会响应)。
Web.config 文件如下所示。
问题是我不知道配置是在多核机器上运行单个进程还是多个进程? 至少我在微软网站上的文档中没有看到。
如何指示 Azure AppService 使用所有内核?
我知道 pm2 npm 模块并且可以使用它,事实上我正在本地机器上使用它。
但是如何让 Azure 使用它呢?
如何告诉 Web.config 使用 pm2
AppService 的最佳实践有一个文档,但它指示仅将 pm2 用于基于 Linux 的 应用服务计划 而不是 Windows。
https://docs.microsoft.com/mt-mt/azure/app-service/app-service-best-practices?toc=%2fazure%2fapp-service%2fcontainers%2ftoc.json&view=azurermps-6.10.0

<?xml version="1.0" encoding="utf-8"?>
<!--
     This configuration file is required if iisnode is used to run node processes behind
     IIS or IIS Express.  For more information, visit:
     https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->

<configuration>
  <system.webServer>
    <!-- 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 this file is a node.js site to be handled by the iisnode module -->
      <add name="iisnode" path="dist/index.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <!-- Do not interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^dist/index.js\/debug[\/]?" />
        </rule>

        <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
        <rule name="StaticContent">
          <action type="Rewrite" url="public{REQUEST_URI}"/>
        </rule>

        <!-- All other URLs are mapped to the node.js site entry point -->
        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
          </conditions>
          <action type="Rewrite" url="dist/index.js"/>
        </rule>
      </rules>
    </rewrite>

    <!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
    <security>
      <requestFiltering>
        <hiddenSegments>
          <remove segment="bin"/>
        </hiddenSegments>
      </requestFiltering>
    </security>

    <!-- Make sure error responses are left untouched -->
    <httpErrors existingResponse="PassThrough" />

    <!--
      You can control how Node is hosted within IIS using the following options:
        * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
        * node_env: will be propagated to node as NODE_ENV environment variable
        * debuggingEnabled - controls whether the built-in debugger is enabled

      See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
    -->
    <!--<iisnode watchedFiles="web.config;*.js"/>-->
  </system.webServer>
</configuration>

【问题讨论】:

    标签: node.js azure azure-web-app-service azure-app-service-plans


    【解决方案1】:

    查看您的 web.config 文件:

    <!--
      You can control how Node is hosted within IIS using the following options:
        * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
        * node_env: will be propagated to node as NODE_ENV environment variable
        * debuggingEnabled - controls whether the built-in debugger is enabled
    
      See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
    -->
    <!--<iisnode watchedFiles="web.config;*.js"/>-->
    

    如果你点击那里提供的链接,你会看到你可以设置这个:

    • nodeProcessCountPerApplication - IIS 将为每个应用程序启动的 node.exe 进程数; 将此值设置为 0 会导致为机器上的每个处理器创建一个 node.exe 进程

    所以:

    <iisnode nodeProcessCountPerApplication="0"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-16
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      • 1970-01-01
      • 2017-05-28
      • 1970-01-01
      相关资源
      最近更新 更多