Azure:容器未在预期时间内启动(WebApp)

编程入门 行业动态 更新时间:2024-10-14 16:26:31
本文介绍了Azure:容器未在预期时间内启动(WebApp)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在尝试部署 web 应用时遇到以下错误:

I'm getting the following error when trying to deploy a webapp:

错误 - 站点 XXX 的容器 XXX_0 未在预期时间限制内启动.经过时间 = 1800.4463925 秒

我正在尝试部署节点应用程序.使用带有 .deployment 文件的自动部署..deployment 文件如下所示:

I'm trying to deploy a node app. Using automatic deployment with a .deployment file. The .deployment file looks as follows:

# 1. KuduSync if [[ "$IN_PLACE_DEPLOYMENT" -ne "1" ]]; then "$KUDU_SYNC_CMD" -v 50 -f "$DEPLOYMENT_SOURCE" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg; .deployment;deploy.sh" exitWithMessageOnError "Kudu Sync failed" fi # 2. Select node version selectNodeVersion # 3. Install npm packages for root directory if [ -e "$DEPLOYMENT_TARGET/package.json" ]; then cd "$DEPLOYMENT_TARGET" # echo "Running $NPM_CMD install --production for root directory" # eval $NPM_CMD install --production echo "Running $NPM_CMD install --production for root directory" eval $NPM_CMD install exitWithMessageOnError "npm failed" ################## echo Building App... eval $NPM_CMD run build ################## echo Starting App... # eval $NPM_CMD run start # cd - > /dev/null fi ##################################################################################### echo "Finished successfully."

package.json 文件有以下脚本:

The package.json file has the following script:

"scripts": { "dev": "node server.js", "build": "next build", "start": "echo 'work!!' && NODE_ENV=production && node server.js" }

而server.js如下:

And server.js is as follows:

const { createServer } = require('http') const next = require('next') const app = next({ dev: process.env.NODE_ENV !== 'production' }) const routes = require('./routes') const handler = routes.getRequestHandler(app) console.log("HEYYYY"); // Without express app.prepare() .then(() => { console.log("Ready on Localhost:80!!!"); createServer(handler) .listen(80, (err) => { if (err) throw err; console.log("Ready on Localhost:80"); }); })

我从研究中收集到的是:

What I've gathered from research is that:

  • 应用启动时间不够
  • 端口未打开/未响应 启动时ping
  • 为了解决 (1) 我将 WEBSITES_CONTAINER_START_TIME_LIMIT 设置为 1800(这是最大值)

    To solve (1) I set WEBSITES_CONTAINER_START_TIME_LIMIT to 1800 (which is the max)

    为了解决 (2) 我将 WEBSITES_PORT(在应用程序设置中)的值设置为80"以公开该端口.(根据文档)

    To solve (2) I set WEBSITES_PORT (in app setting) with a value of "80" to expose that port. (As per documentation)

    还有什么我应该尝试的吗?

    Any others things I should try ?

    PS 默认的 docker 日志文件输出如下:

    PS the default docker log file outputs the following:

    2018-10-15T14:32:59.946431939Z > XXX@1.0.0 start /home/site/wwwroot 2018-10-15T14:32:59.946455839Z > echo 'work!!' && NODE_ENV=production && node server.js 2018-10-15T14:32:59.946462839Z 2018-10-15T14:33:00.249554126Z work!! 2018-10-15T14:34:41.634101502Z HEYYYY 2018-10-15T14:35:38.838555689Z DONE Compiled successfully in 48099ms14:35:38 2018-10-15T14:35:38.838868291Z 2018-10-15T14:35:39.406086808Z Ready on Localhost:80!!! 2018-10-15T14:35:39.460029162Z Ready on Localhost:80

    推荐答案

    我在 Azure App Service Deploy 中同时设置 -Port 80 和 -WEBSITES_PORT 80 任务,azure devops 中的 App Settings 部分有所帮助.它使 docker 从端口 80 而不是 8000 开始.它位于 该任务的应用设置使用示例.

    For me setting both -Port 80 and -WEBSITES_PORT 80 in Azure App Service Deploy task, App Settings section in azure devops helped. It made docker to start with port 80 instead of 8000. It is in example of app setting usage for that task.

    更多推荐

    Azure:容器未在预期时间内启动(WebApp)

    本文发布于:2023-11-27 13:33:18,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1638286.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:时间内   容器   Azure   WebApp

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!