将标志传递给 Azure Web 应用程序中 NodeJS 的 Chrome V8 引擎
Pass flags to NodeJS's Chrome V8 engine in Azure Web Apps
我已经在 Azure Web Apps 上部署了 NodeJS 应用程序。如何将标志传递给 NodeJS 的 Chrome V8 引擎?
在我的本地机器上,我可以很容易地做到这一点,而 运行 服务器脚本如下。
node -nouse-idle-notification -expose-gc -max-old-space-size=8192 server.js
在 Azure Web 应用程序中的何处指定这些标志?
您可以在 iisnode.yml
或 web.config
中执行此操作。如果您通过 git 进行部署,您的存储库中可能没有这些。您可以使用 Kudu Console 并在 d:\home\site\wwwroot
下找到默认生成的 web.config
。默认情况下,根本没有 iisnode.yml
。
使用iisnode.yml
只需将以下行放入 iisnode.yml
:
nodeProcessCommandLine: node.exe --nouse-idle-notification --expose-gc --max-old-space-size=1024
或者,如果您使用 Node 版本的完整路径,则需要引用它,例如
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs.7.1\node.exe" --nouse-idle-notification --expose-gc --max-old-space-size=1024
使用web.config
在文件末尾,您会看到一个注释掉的 <iisnode>
标记。用这样的东西替换它:
<iisnode nodeProcessCommandLine="node.exe --nouse-idle-notification --expose-gc --max-old-space-size=1024"/>
备注
iisnode.yml
优先于 web.config
- 我降低了你的
max-old-space-size
值,因为我尝试时它已经爆炸了,但这是正交的。
然后使用任一文件,您都可以在您的存储库中提交它们,这样它就可以在部署时使用。
我已经在 Azure Web Apps 上部署了 NodeJS 应用程序。如何将标志传递给 NodeJS 的 Chrome V8 引擎?
在我的本地机器上,我可以很容易地做到这一点,而 运行 服务器脚本如下。
node -nouse-idle-notification -expose-gc -max-old-space-size=8192 server.js
在 Azure Web 应用程序中的何处指定这些标志?
您可以在 iisnode.yml
或 web.config
中执行此操作。如果您通过 git 进行部署,您的存储库中可能没有这些。您可以使用 Kudu Console 并在 d:\home\site\wwwroot
下找到默认生成的 web.config
。默认情况下,根本没有 iisnode.yml
。
使用iisnode.yml
只需将以下行放入 iisnode.yml
:
nodeProcessCommandLine: node.exe --nouse-idle-notification --expose-gc --max-old-space-size=1024
或者,如果您使用 Node 版本的完整路径,则需要引用它,例如
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs.7.1\node.exe" --nouse-idle-notification --expose-gc --max-old-space-size=1024
使用web.config
在文件末尾,您会看到一个注释掉的 <iisnode>
标记。用这样的东西替换它:
<iisnode nodeProcessCommandLine="node.exe --nouse-idle-notification --expose-gc --max-old-space-size=1024"/>
备注
iisnode.yml
优先于web.config
- 我降低了你的
max-old-space-size
值,因为我尝试时它已经爆炸了,但这是正交的。
然后使用任一文件,您都可以在您的存储库中提交它们,这样它就可以在部署时使用。