将 Express App 部署到 Azure App Services 未响应端口上的 HTTP ping:8080
Deploy Express App to Azure App Services didn't respond to HTTP pings on port: 8080
我尝试将我的 NestJs 应用程序(使用快速适配器)部署到 Azure 应用服务。在 docker 日志中我得到这个错误:
2020-11-20T10:42:02.911Z INFO - docker run -d -p 8947:8080 --name xxx_0_37a36398 -e WEBSITES_PORT=8080 -e WEBSITE_SITE_NAME=xxx -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=xxx.azurewebsites.net -e WEBSITE_INSTANCE_ID=xxx appsvc/node:14-lts_20200918.1 yarn start:prod
2020-11-20T10:42:02.912Z INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2020-11-20T10:42:05.088Z INFO - Initiating warmup request to container xxx_0_37a36398 for site xxx
2020-11-20T10:42:20.586Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 15.4982001 sec
2020-11-20T10:48:35.794Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 390.7060158 sec
2020-11-20T10:56:21.027Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 855.9388558 sec
2020-11-20T11:04:08.996Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 1323.907606 sec
2020-11-20T11:11:55.596Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 1790.5073044 sec
2020-11-20T11:12:25.625Z ERROR - Container xxx_i_0_37a36398 for site xxx did not start within expected time limit. Elapsed time = 1820.5363685 sec
2020-11-20T11:12:25.627Z ERROR - Container xxx_0_37a36398 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2020-11-20T11:12:25.637Z INFO - Stopping site xxx because it failed during startup.
应用程序日志显示应用程序启动成功
2020-11-20T10:42:05.150205868Z _____
2020-11-20T10:42:05.150227670Z / _ \ __________ _________ ____
2020-11-20T10:42:05.150232970Z / /_\ \___ / | \_ __ \_/ __ \
2020-11-20T10:42:05.150237271Z / | \/ /| | /| | \/\ ___/
2020-11-20T10:42:05.150241271Z \____|__ /_____ \____/ |__| \___ >
2020-11-20T10:42:05.150245371Z \/ \/ \/
2020-11-20T10:42:05.150249272Z A P P S E R V I C E O N L I N U X
2020-11-20T10:42:05.150252972Z
2020-11-20T10:42:05.150256472Z Documentation: http://aka.ms/webapp-linux
2020-11-20T10:42:05.150260173Z NodeJS quickstart: https://aka.ms/node-qs
2020-11-20T10:42:05.150263673Z NodeJS Version : v14.7.0
2020-11-20T10:42:05.150267273Z Note: Any data outside '/home' is not persisted
2020-11-20T10:42:05.150270874Z
2020-11-20T10:42:05.388794060Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-11-20T10:42:05.389362508Z Could not find operation ID in manifest. Generating an operation id...
2020-11-20T10:42:05.389393011Z Build Operation ID: 5488a73a-f6e1-48d5-9360-7d4e0db141f4
2020-11-20T10:42:06.033354810Z Environment Variables for Application Insight's Codeless Configuration exists..
2020-11-20T10:42:06.603097828Z Writing output script to '/opt/startup/startup.sh'
2020-11-20T10:42:06.946048753Z Running #!/bin/sh
2020-11-20T10:42:06.946644503Z
2020-11-20T10:42:06.946657204Z # Enter the source directory to make sure the script runs where the user expects
2020-11-20T10:42:06.946662305Z cd "/home/site/wwwroot"
2020-11-20T10:42:06.946666105Z
2020-11-20T10:42:06.947939813Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
2020-11-20T10:42:06.947952014Z if [ -z "$PORT" ]; then
2020-11-20T10:42:06.947956114Z export PORT=8080
2020-11-20T10:42:06.949015304Z fi
2020-11-20T10:42:06.954862399Z
2020-11-20T10:42:06.954927704Z export NODE_OPTIONS='--require /usr/local/lib/node_modules/applicationinsights/out/Bootstrap/Oryx.js ' $NODE_OPTIONS
2020-11-20T10:42:06.954986409Z PATH="$PATH:/home/site/wwwroot" yarn start:prod
2020-11-20T10:42:08.321443397Z yarn run v1.17.3
2020-11-20T10:42:08.484387733Z $ node dist/src/main
[...]
2020-11-20T10:42:23.394152218Z Application started on port 8080
我用这条线绑定了快递服务器
const port = Number(process.env.PORT) || 8080;
我在谷歌上搜索了一段时间以找到解决方案,但无济于事。这是我现在尝试使用的步骤。
- 增加
WEBSITES_CONTAINER_START_TIME_LIMIT
到 1800
- 将
WEBSITES_PORT
和 PORT
设置为 80
- 重新创建并重新部署应用程序
有谁知道为什么仍然会出现此问题?我的应用程序在正确的端口上列出,returns /
下的 200 Http 状态并且还实现了 400 错误处理程序(我读到这个云也是一个问题)。
采购自https://docs.microsoft.com/azure/app-service/faq-app-service-linux#custom-containers
My custom container listens to a port other than port 80. How can I configure my app to route requests to that port?
We have automatic port detection. You can also specify an app setting
called WEBSITES_PORT and give it the value of the expected port
number. Previously, the platform used the PORT app setting. We are
planning to deprecate this app setting and to use WEBSITES_PORT
exclusively.
You don’t need to use the PORT variable. The automatic port detection
detects the port (port 80 is the default), we will attempt to detect
which port to bind to your container, but you can also use the
WEBSITES_PORT app setting and configure it with a value for the port you want to bind to your container. However, the web server in your
custom image may use a port other than 80. You tell Azure about the
port that your custom container uses by using the WEBSITES_PORT app
setting. For using a different port - Use the EXPOSE instruction in
your Dockerfile to expose the appropriate port (E.g 5000) and use the
WEBSITES_PORT app setting on Azure with a value of "5000" to expose that port.
您可能使用 Sentry 吗?我们遇到了类似的问题,并且能够将其追溯到 Sentry。在没有哨兵和默认配置的情况下尝试。
我尝试将我的 NestJs 应用程序(使用快速适配器)部署到 Azure 应用服务。在 docker 日志中我得到这个错误:
2020-11-20T10:42:02.911Z INFO - docker run -d -p 8947:8080 --name xxx_0_37a36398 -e WEBSITES_PORT=8080 -e WEBSITE_SITE_NAME=xxx -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=xxx.azurewebsites.net -e WEBSITE_INSTANCE_ID=xxx appsvc/node:14-lts_20200918.1 yarn start:prod
2020-11-20T10:42:02.912Z INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2020-11-20T10:42:05.088Z INFO - Initiating warmup request to container xxx_0_37a36398 for site xxx
2020-11-20T10:42:20.586Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 15.4982001 sec
2020-11-20T10:48:35.794Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 390.7060158 sec
2020-11-20T10:56:21.027Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 855.9388558 sec
2020-11-20T11:04:08.996Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 1323.907606 sec
2020-11-20T11:11:55.596Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 1790.5073044 sec
2020-11-20T11:12:25.625Z ERROR - Container xxx_i_0_37a36398 for site xxx did not start within expected time limit. Elapsed time = 1820.5363685 sec
2020-11-20T11:12:25.627Z ERROR - Container xxx_0_37a36398 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2020-11-20T11:12:25.637Z INFO - Stopping site xxx because it failed during startup.
应用程序日志显示应用程序启动成功
2020-11-20T10:42:05.150205868Z _____
2020-11-20T10:42:05.150227670Z / _ \ __________ _________ ____
2020-11-20T10:42:05.150232970Z / /_\ \___ / | \_ __ \_/ __ \
2020-11-20T10:42:05.150237271Z / | \/ /| | /| | \/\ ___/
2020-11-20T10:42:05.150241271Z \____|__ /_____ \____/ |__| \___ >
2020-11-20T10:42:05.150245371Z \/ \/ \/
2020-11-20T10:42:05.150249272Z A P P S E R V I C E O N L I N U X
2020-11-20T10:42:05.150252972Z
2020-11-20T10:42:05.150256472Z Documentation: http://aka.ms/webapp-linux
2020-11-20T10:42:05.150260173Z NodeJS quickstart: https://aka.ms/node-qs
2020-11-20T10:42:05.150263673Z NodeJS Version : v14.7.0
2020-11-20T10:42:05.150267273Z Note: Any data outside '/home' is not persisted
2020-11-20T10:42:05.150270874Z
2020-11-20T10:42:05.388794060Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-11-20T10:42:05.389362508Z Could not find operation ID in manifest. Generating an operation id...
2020-11-20T10:42:05.389393011Z Build Operation ID: 5488a73a-f6e1-48d5-9360-7d4e0db141f4
2020-11-20T10:42:06.033354810Z Environment Variables for Application Insight's Codeless Configuration exists..
2020-11-20T10:42:06.603097828Z Writing output script to '/opt/startup/startup.sh'
2020-11-20T10:42:06.946048753Z Running #!/bin/sh
2020-11-20T10:42:06.946644503Z
2020-11-20T10:42:06.946657204Z # Enter the source directory to make sure the script runs where the user expects
2020-11-20T10:42:06.946662305Z cd "/home/site/wwwroot"
2020-11-20T10:42:06.946666105Z
2020-11-20T10:42:06.947939813Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
2020-11-20T10:42:06.947952014Z if [ -z "$PORT" ]; then
2020-11-20T10:42:06.947956114Z export PORT=8080
2020-11-20T10:42:06.949015304Z fi
2020-11-20T10:42:06.954862399Z
2020-11-20T10:42:06.954927704Z export NODE_OPTIONS='--require /usr/local/lib/node_modules/applicationinsights/out/Bootstrap/Oryx.js ' $NODE_OPTIONS
2020-11-20T10:42:06.954986409Z PATH="$PATH:/home/site/wwwroot" yarn start:prod
2020-11-20T10:42:08.321443397Z yarn run v1.17.3
2020-11-20T10:42:08.484387733Z $ node dist/src/main
[...]
2020-11-20T10:42:23.394152218Z Application started on port 8080
我用这条线绑定了快递服务器
const port = Number(process.env.PORT) || 8080;
我在谷歌上搜索了一段时间以找到解决方案,但无济于事。这是我现在尝试使用的步骤。
- 增加
WEBSITES_CONTAINER_START_TIME_LIMIT
到 1800 - 将
WEBSITES_PORT
和PORT
设置为 80 - 重新创建并重新部署应用程序
有谁知道为什么仍然会出现此问题?我的应用程序在正确的端口上列出,returns /
下的 200 Http 状态并且还实现了 400 错误处理程序(我读到这个云也是一个问题)。
采购自https://docs.microsoft.com/azure/app-service/faq-app-service-linux#custom-containers
My custom container listens to a port other than port 80. How can I configure my app to route requests to that port?
We have automatic port detection. You can also specify an app setting called WEBSITES_PORT and give it the value of the expected port number. Previously, the platform used the PORT app setting. We are planning to deprecate this app setting and to use WEBSITES_PORT exclusively.
You don’t need to use the PORT variable. The automatic port detection detects the port (port 80 is the default), we will attempt to detect which port to bind to your container, but you can also use the WEBSITES_PORT app setting and configure it with a value for the port you want to bind to your container. However, the web server in your custom image may use a port other than 80. You tell Azure about the port that your custom container uses by using the WEBSITES_PORT app setting. For using a different port - Use the EXPOSE instruction in your Dockerfile to expose the appropriate port (E.g 5000) and use the WEBSITES_PORT app setting on Azure with a value of "5000" to expose that port.
您可能使用 Sentry 吗?我们遇到了类似的问题,并且能够将其追溯到 Sentry。在没有哨兵和默认配置的情况下尝试。