我们在 Windows 2008R2 服务器上将 iisnode 与 IIS 7.5 结合使用。 node.js 应用程序在启动时会加载一些配置数据。配置数据有时会发生变化,应用程序需要重新启动。
当通过 Windows 系统管理器控制台重新启动 IIS 站点实例时,一切正常。
当通过 appcmd stop
和 appcmd start
命令重新启动 IIS 时,node.js-app 不会再次启动。看起来 iisnode 不识别 IIS 的重启。
如何通过命令(即通过命令行)重启 iisnode 环境中的 node.js 应用程序?
最佳答案
您可以使用 Web.config
文件中 iisnode
元素的 watchedFiles
属性通过 IISNode 自动回收站点。我知道这不是通过命令行,但从你的问题来看,这似乎也可以解决问题,不需要任何人的手动干预。
使用以下信息,您可以将 IISNode 设置为监视您的配置文件,并且只要它们发生更改,IISNode 就会回收该站点。
Comment from IISNode Sample Config
watchedFiles - semi-colon separated list of files that will be watched for changes; a change to a file causes the application to recycle;
each entry consists of an optional directory name plus required file name which are relative to the directory where the main application entry point is located;
wild cards are allowed in the file name portion only; for example: "*.js;node_modules\foo\lib\options.json;app_data*.config.json"
来自 Web.config 的示例 iisnode
元素将在 Web.config 发生更改或应用程序顶级文件夹中的任何 .js 文件时回收站点。
<iisnode
node_env="%node_env%"
nodeProcessCountPerApplication="1"
maxConcurrentRequestsPerProcess="1024"
maxNamedPipeConnectionRetry="100"
namedPipeConnectionRetryDelay="250"
maxNamedPipeConnectionPoolSize="512"
maxNamedPipePooledConnectionAge="30000"
asyncCompletionThreadCount="0"
initialRequestBufferSize="4096"
maxRequestBufferSize="65536"
uncFileChangesPollingInterval="5000"
gracefulShutdownTimeout="60000"
loggingEnabled="true"
logDirectory="iisnode"
debuggingEnabled="true"
debugHeaderEnabled="false"
debuggerPortRange="5058-6058"
debuggerPathSegment="debug"
maxLogFileSizeInKB="128"
maxTotalLogFileSizeInKB="1024"
maxLogFiles="20"
devErrorsEnabled="true"
flushResponse="false"
enableXFF="false"
promoteServerVars=""
configOverrides="iisnode.yml"
watchedFiles="web.config;*.js"
nodeProcessCommandLine="C:\Program Files (x86)\nodejs\node.exe" />
关于node.js - 如何重启iisnode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34613891/