Linux 上的 Azure Web 应用程序:“错误:容器未响应端口:8080 上的 HTTP ping"- 使用时:“开始":“pm2 start 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"

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

问题描述

如果我的节点应用正在使用启动脚本,我的应用服务 Linux 实例会崩溃:"start": "pm2 start server.js":

My App Service Linux instance crashes if my node app is using the start script: "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", 应用程序启动就好了.

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

我知道如果容器没有通过 8080 响应容器会停止,但我将 process.env.PORT 设置为我的服务器的端口,所以我无法确定找出为什么 pm2 start 脚本会导致容器崩溃.

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.

我有一种感觉,如果使用上面的启动脚本,process.env.PORT 是未定义的,因为过程中有一些混淆,但找不到任何调试方法,因为 之后容器崩溃了,我无法再通过 ssh 进入它来检查它.

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.

推荐答案

我也遇到了同样的问题.当我将 server.js 文件中的代码更改为以下代码时,它成功运行:

I was having the same issue. When I changed the code in my server.js file to the below it succesfully ran:

const port = process.env.port || 8080;

重新部署到 Azure 后,它现在可以工作了.

After redeploying to Azure it is now working.

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

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