7

I have deployed NodeJS application on Azure Web Apps. How to pass flags to NodeJS's Chrome V8 engine?

In my local machine I can do it easily while running the server script as below.

node -nouse-idle-notification -expose-gc -max-old-space-size=8192 server.js

Where to specify these flags in Azure Web Apps?

Nicool
  • 259
  • 1
  • 7

1 Answers1

11

You can do this either in iisnode.yml or in web.config. If you are deploying via git, you likely don't have those in your repo. You can get the default generated web.config by using Kudu Console and finding it under d:\home\site\wwwroot. By default, there is no iisnode.yml at all.

Using iisnode.yml

Just put the following line in the iisnode.yml:

nodeProcessCommandLine: node.exe --nouse-idle-notification --expose-gc --max-old-space-size=1024

Or if you use a full path to a version of Node, you'll need to quote it, e.g.

nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\5.7.1\node.exe" --nouse-idle-notification --expose-gc --max-old-space-size=1024

Using web.config

Toward the end of the file, you'll see a commented out <iisnode> tag. Replace it by something like this:

<iisnode nodeProcessCommandLine="node.exe --nouse-idle-notification --expose-gc --max-old-space-size=1024"/>

Notes

  • iisnode.yml takes precedence over web.config
  • I lowered your max-old-space-size value as that was blowing up when I tried, but that's orthogonal.

Then with either file, you can commit them in your repo so it just works on deployment.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Thanks for the clear answer. I found both `iisnode.yml` and `web.config` files under `d:\home\site\wwwroot` by default. When I set flags using `iisnode.yml` my application didn't run after deployment. However is no issue with 2nd approach i.e. using `web.config`. – Nicool May 29 '16 at 04:42
  • 2
    Make sure you get the double quotes right in the yml case, as in my example. If you quote the whole thing it doesn't work. – David Ebbo May 29 '16 at 05:17
  • 2
    Adding to `iisnode.yml` will let Azure simply not start my application. Adding to `web.config` has no effect in my app. Node still crashes where the memory usage is high. – Gao Shenghan Aug 03 '18 at 01:50