Linux上的Azure Web App:“错误:容器未响应端口:8080上的HTTP ping" -使用时:“启动":"pm2启动server.js"; [英] Azure Web App on Linux: "Error: Container didn't respond to HTTP pings on port: 8080" - when using: "start": "pm2 start server.js"

查看:197
本文介绍了Linux上的Azure Web App:“错误:容器未响应端口:8080上的HTTP ping" -使用时:“启动":"pm2启动server.js";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的节点应用程序使用启动脚本,则我的App Service Linux实例崩溃:"start": "pm2 start server.js":

2019-04-15 11:36:34.432 ERROR - Container crime-digest__6ea5_0 for site crime-digest__6ea5 has exited, failing site start
2019-04-15 11:36:34.489 ERROR - Container crime-digest__6ea5_0 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.

容器日志只有上述错误.如果我只使用:"start": "node server.js",应用程序就可以正常启动.

我知道,如果容器没有通过8080响应,容器将停止运行,但是我将process.env.PORT设置为服务器的端口,所以我不知道为什么pm2启动脚本会使容器崩溃

如果使用上面的启动脚本,我感觉process.env.PORT是未定义的,因为过程中有些混淆,但是找不到任何方法对其进行调试,因为在容器崩溃后,我无法ssh进去进行检查.

我真的很感谢任何建议, 谢谢.

解决方案

我们是否要对PORT 8080进行ping操作?这里的问题是端口8080没有暴露,因此当我们尝试对容器执行ping操作时,我们并未对容器正在侦听的端口执行ping操作.

有两种解决方法.

  1. 使用Dockerfile中的EXPOSE指令公开端口8080.
  2. 使用值为"8080"的WEBSITES_PORT应用程序设置公开该端口.

您可以参考以下提到的文章:

https://docs.microsoft.com/zh-cn/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment?view=azure-devops

:

2019-04-15 11:36:34.432 ERROR - Container crime-digest__6ea5_0 for site crime-digest__6ea5 has exited, failing site start
2019-04-15 11:36:34.489 ERROR - Container crime-digest__6ea5_0 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.

Container logs have nothing but the above error. If I use just: "start": "node server.js", the app starts just fine.

I understand that if the container doesn't respond via 8080 the container gets stopped, but I'm having process.env.PORT set as the port of my server so I can't figure out why the pm2 start script crashes the container.

I have a feeling that process.env.PORT is undefined if using the above start script because of some mixup in the process but can't find any way to debug it because after the container crashes I'm unable to ssh into it any more to inspect it.

I would really appreciate any suggestion, Thanks.

解决方案

Are we trying to ping on PORT 8080? The problem here is that port 8080 is not exposed, so when we attempt to ping the container, we aren't pinging on a port on which the container is listening.

There are a couple of ways to resolve this.

  1. Use the EXPOSE instruction in your Dockerfile to expose port 8080.
  2. Use the WEBSITES_PORT app setting with a value of "8080" to expose that port.

You can refer the below mentioned articles:

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment?view=azure-devops

https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/

这篇关于Linux上的Azure Web App:“错误:容器未响应端口:8080上的HTTP ping" -使用时:“启动":"pm2启动server.js";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆