【发布时间】:2021-06-10 18:22:06
【问题描述】:
我使用 Windows Server Standard 2019 托管带有 ASP.net Core 3.1.1 网站的 Angular 11 Universal。该网站运行良好,直到服务器重新启动。我做了很多测试,以确保 Angular 应用程序没有内存泄漏或一些错误,并且一切都绝对完美。然后我不得不重新启动服务器来安装一些 Windows 更新,然后网站就不再工作了。它会无限加载。
问题是如果我杀死 Node.js JavaScript Runtime 在 后台进程 在服务器重新启动后运行 并立即刷新该网站,Node 将启动一个新进程,该网站将按预期运行,直到下一次服务器重新启动。我进行了许多其他测试以找到特定的案例场景。
所以,我不确定如何解决这个问题。自然,我希望网站在服务器重新启动后立即运行,而无需我的任何干预。以下是我认为应该有助于解决问题的文件和配置,如果您需要其他信息,请告诉我:
网站文件夹结构:
- dist(文件夹)
- iisnode(文件夹)
- main.js
- node_start.cmd
- Web.config
我先安装了 nodejs 14.16.0 LTS,然后安装了 15.11.0 Current,还安装了 Url Rewrite 2.1 和 iisnode-full-v0.2.21-x64强>
IIS 版本为 10。我尝试将应用程序池设置为:
- 立即启动应用程序池
- 启动模式:AlwaysRunning
- 空闲超时操作:挂起
- 最大工作进程数:0
- 已启用预加载:是的
当我在后台终止 Node.js JavaScript 运行时(在服务器重新启动后运行,然后点击刷新以到达网站)时,我重复网站按预期工作。最后,该网站使用有效的 SSL 证书。
这里是node_start.cmd的内容
cd "C:\inetpub\wwwroot\championstogether" "C:\Program 文件\nodejs\node.exe" "C:\inetpub\wwwroot\championstogether\main.js"
然后是 Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="StaticFilesCss" path="*.css" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFilesPng" path="*.png" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="iisnode" path="main.js" verb="*" modules="iisnode" responseBufferLimit="0" />
</handlers>
<iisnode nodeProcessCommandLine="C:\Program Files\nodejs\node.exe --no-deprecation --no-warnings"
flushResponse="false"
promoteServerVars="HTTP_UID,HTTP_PUBCOOKIE_USER,LOGON_USER,HTTP_SHIBSESSIONID"
node_env="production"
nodeProcessCountPerApplication="0"
debugHeaderEnabled="false"
devErrorsEnabled="false"
gracefulShutdownTimeout="60000"
maxConcurrentRequestsPerProcess="1024"
maxNamedPipeConnectionRetry="100"
namedPipeConnectionRetryDelay="250"
maxNamedPipeConnectionPoolSize="512"
maxNamedPipePooledConnectionAge="30000"
asyncCompletionThreadCount="0"
initialRequestBufferSize="4096"
maxRequestBufferSize="65536"
uncFileChangesPollingInterval="5000"
loggingEnabled="true"
logDirectory="iisnode"
debuggingEnabled="true"
debuggerPortRange="5058-6058"
debuggerPathSegment="debug"
maxLogFileSizeInKB="128"
maxTotalLogFileSizeInKB="1024"
maxLogFiles="20"
enableXFF="false"
configOverrides="iisnode.yml"
watchedFiles="web.config;*.js;routes\*.js;views\*.pug"/>
<rewrite>
<rules>
<rule name="DynamicContent">
<match url="/*" />
<action type="Rewrite" url="main.js" />
</rule>
<rule name="StaticContent" stopProcessing="true">
<match url="([\S]+[.](jpg|jpeg|gif|css|png|js|ts|cscc|less|ico|html|map|svg))" />
<action type="None" />
</rule>
<rule name="SocketIO" patternSyntax="ECMAScript">
<match url="socket.io.+"/>
<action type="Rewrite" url="main.js"/>
</rule>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^main.js\/debug[\/]?"/>
</rule>
</rules>
</rewrite>
<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />
<modules runAllManagedModulesForAllRequests="false" />
<staticContent>
<clientCache cacheControlMode="UseMaxAge" />
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".ttf" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<remove fileExtension=".otf" />
<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/x-woff" />
<mimeMap fileExtension=".otf" mimeType="application/otf" />
</staticContent>
</system.webServer>
</location>
</configuration>
感谢您的帮助,
萨曼莎
【问题讨论】:
标签: node.js iis angular-universal windows-server