1
votes

I have created a nodeJs application and have deployed it to Azure AppService using Azure Devops (VSTS).
I have to specify the Web.config to run my Node Application (Other wise the Azure AppService application does not respond).
The Web.config file can be seen below.
The problem is I am not aware whether the configuration will run a single porcess or multiple on a multiCore machine?
Atleast I have not seen that on the documentation on microsoft website.
How can I instruct Azure AppService to use all the cores?
I know of the pm2 npm module and that it could be used and infact I am using it on my local machine.
But how do I tell Azure to use it?
How can I tell the Web.config to use pm2?
There is a documentation for best practices for AppService, but it instructs to use pm2 only for Linux based App Service Plan and not Windows one.
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>
1

1 Answers

1
votes

Look in your web.config file:

<!--
  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"/>-->

If you follow the link provided there, you will see that you can set this:

  • nodeProcessCountPerApplication - number of node.exe processes that IIS will start per application; setting this value to 0 results in creating one node.exe process per each processor on the machine

So:

<iisnode nodeProcessCountPerApplication="0"/>