首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >利用MultiCore应用服务计划(Windows)实现Azure应用服务中的NodeJs

利用MultiCore应用服务计划(Windows)实现Azure应用服务中的NodeJs
EN

Stack Overflow用户
提问于 2018-10-30 10:46:14
回答 1查看 309关注 0票数 1

我创建了一个nodeJs应用程序,并使用Azure (VSTS)将其部署到Azure AppService

我必须指定运行Node应用程序的Web.config (其他明智的是,Azure AppService应用程序没有响应)。

下面可以看到Web.config文件

问题是,我不知道配置是在multiCore机器上运行单个进程还是多个进程?

至少我还没有在微软网站的文档中看到这一点。

如何指示Azure AppService使用所有核心?

我知道pm2 npm模块,它可以使用,事实上我正在本地机器上使用它。

但我该怎么告诉Azure用它呢?

如何告诉Web.config使用pm2

有一个关于AppService的最佳实践的文档,但是它指示只在基于Linux的应用程序服务计划而不是Windows中使用pm2

https://learn.microsoft.com/mt-mt/azure/app-service/app-service-best-practices?toc=%2fazure%2fapp-service%2fcontainers%2ftoc.json&view=azurermps-6.10.0

代码语言:javascript
复制
<?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>
EN

回答 1

Stack Overflow用户

发布于 2018-11-14 15:55:24

查看您的web.config文件:

代码语言:javascript
复制
<!--
  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进程。

所以:

代码语言:javascript
复制
<iisnode nodeProcessCountPerApplication="0"/>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53062602

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档