我有一个使用IISNode运行Node.js应用程序的Azure应用服务。问题是
process.env.PORT
未定义。我已经阅读过,IISNode使用一种称为命名管道的东西,并且端口信息可能不易读取(?),但在我的情况下,我只得到未定义。 我尝试部署的项目可以在GitHub上找到。 我确实定义了Web.config文件,它看起来像这样: <handlers>
<!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
<add name="iisnode" path="index.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^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 application entry point -->
<rule name="DynamicContent">
<match url="/*" />
<action type="Rewrite" url="index.js" />
</rule>
</rules>
</rewrite>
<!-- You can control how Node is hosted within IIS using the following options -->
<!--<iisnode
node_env="%node_env%"
nodeProcessCountPerApplication="1"
maxConcurrentRequestsPerProcess="1024"
maxNamedPipeConnectionRetry="3"
namedPipeConnectionRetryDelay="2000"
maxNamedPipeConnectionPoolSize="512"
maxNamedPipePooledConnectionAge="30000"
asyncCompletionThreadCount="0"
initialRequestBufferSize="4096"
maxRequestBufferSize="65536"
watchedFiles="*.js"
uncFileChangesPollingInterval="5000"
gracefulShutdownTimeout="60000"
loggingEnabled="true"
logDirectoryNameSuffix="logs"
debuggingEnabled="true"
debuggerPortRange="5058-6058"
debuggerPathSegment="debug"
maxLogFileSizeInKB="128"
appendToExistingLog="false"
logFileFlushInterval="5000"
devErrorsEnabled="true"
flushResponse="false"
enableXFF="false"
promoteServerVars=""
/>-->
<iisnode watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade;views\account\*.jade;iisnode.yml" />
</system.webServer>
我编写了一份Kudu脚本,用于构建资源并将其复制到% DEPLOYMENT_TARGET%。
我错过了什么?任何帮助都将不胜感激!
更新
我花费了数小时的时间,在多个日期内找出了导致进程未启动,因此环境变量未定义的原因。我在Heroku上运行应用程序只花了15分钟,所以我猜这仍然是一个谜(至少对我来说是这样)。
\\.\pipe\e317fe18-7017-4a09-84fb-773a54cf0738
。此外,尝试使用一个微不足道的Node应用进行隔离。 - David Ebbo