Azure部署失败-容器未响应端口8080上的HTTP ping,站点启动失败 [英] Azure Deployment Failure - Container didn't respond to HTTP pings on port: 8080, failing site start

查看:88
本文介绍了Azure部署失败-容器未响应端口8080上的HTTP ping,站点启动失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在部署在Azure App Service上使用NodeJS,Express和React的Web应用程序(已插入我的BitBucket存储库中),但没有找到成功.要么部署失败,要么声称部署成功,但是该站点不可访问并且一直处于超时状态.当我在Azure诊断中检查Docker日志时,我注意到以下内容:

I am deploying a web application that uses NodeJS, Express and React on Azure App Service (plugged to my BitBucket repo), and I'm not finding success. Either the deployment fails, or it claims it is successful, but the site is unaccessible and keeps timing out. When I check the Docker logs in my Azure diagnosis, I notice the following:

2021-02-14T13:41:53.578Z INFO  - Initiating warmup request to container mcm-app_0_543ad0c3 for site mcm-app

几行日志读取等待对容器mcm-app_0_543ad0c3的预热请求的响应之后,我得到以下信息:

And after several logs that read Waiting for response to warmup request for container mcm-app_0_543ad0c3, I get the following:

2021-02-14T13:45:44.205Z ERROR - Container mcm-app_0_543ad0c3 for site mcm-app did not start within expected time limit. Elapsed time = 230.6269687 sec
2021-02-14T13:45:44.236Z ERROR - Container mcm-app_0_543ad0c3 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2021-02-14T13:45:44.299Z INFO  - Stopping site mcm-app because it failed during startup.

这是我用于Express后端的 server.js 文件的样子:

This is what my server.js file for the Express backend looks like:

var express = require("express");
var cors = require("cors");
var app = express();
var path = require("path");

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

// Enable CORS and handle JSON requests
app.use(cors());
app.use(express.json());

app.post("/", function (req, res, next) {
  // console.log(req.body);
  res.json({ msg: "This is CORS-enabled for all origins!" });
});

// Set router for email notifications
const mailRouter = require("./routers/mail");
const readerRouter = require("./routers/reader");
const notificationsRouter = require("./routers/booking-notifications");
app.use("/email", mailRouter);
app.use("/reader", readerRouter);
app.use("/notifications", notificationsRouter);


app.use(express.static("./mcm-app/build"));
app.get("*", (req, res) => {
  res.sendFile(path.join(__dirname, "mcm-app", "build", "index.html"));
});

app.listen(port, () => {
  // console.log(`Server is running on port: ${port}`);
});

顺便说一下,我客户的 package.json 不包含任何 proxy 命令.我删除了无论如何,都会显示错误,有/无错误.

My client's package.json does not contain any proxy command, by the way. I removed it. The error appears with/without it anyway.

此外,根据一些建议,我尝试在Azure配置中将 WEBSITES_PORT 设置为8080.但是到目前为止没有任何效果.

Also, per some recommendations, I've tried setting WEBSITES_PORT to 8080 in my Azure configurations. But nothing works so far.

如果能得到一些详细的指导来解决此问题,我将不胜感激.我不使用.yml文件,以防万一.

I'd appreciate it if I could get some detailed guidance to resolve this. I'm not using a .yml file, in case that helps.

推荐答案

我发现Isaac已通过以下解决方案成功解决了此问题.

I found Isaac has managed to resolve this issue with below solution.

添加tty:在docker-compose.yml文件中为true.另外,要使前端与后端之间的交互按预期在应用程序中正常工作,请将客户端的package.json中的proxy命令更改为以下内容:

Adding tty: true for it in docker-compose.yml file. Also, to make the frontend-backend interaction work as expected in the app, changing proxy command in client's package.json to the following:

"proxy":"http://backend:5000"

然后将docker-compose.yml中的链接命令更改为此:

And changing links command in docker-compose.yml to this:

  - "backend:be"

在此处共享答案,以帮助将来可能会遇到相同问题的其他人.

Sharing the answer here to help others who may encounter the same issue in the future.

这篇关于Azure部署失败-容器未响应端口8080上的HTTP ping,站点启动失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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