问题描述: 项目代码更新之后去接口访问出现了502的错误; 一开始以为是nginx配置出错了,但一想没有改动里面的配置; 然后敲了一下pm2 list命令,看看启动的情况,发现在status那一栏是errored; "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20240927/98da1db1205eb89f6ccab339aec57e33.png) pm2 logs www日志 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20240927/9fd0a9471634374762853386a55c83f4.png) Nginx error.log 2024/05/28 02:00:38 [error] 15003#0: *3531770 connect() failed (111: Connection refused) while connecting to upstream, client: 125.111.47.152, server: _, request: "GET /mgzapi/userOOTD/all HTTP/1.1", upstream: "http://127.0.0.1:5050/mgzapi/userOOTD/all", host: "biguden.cn:5000", referrer: "https://servicewechat.com/wxc47531ec5d63e70/devtools/page-frame.html" 2024/05/28 02:00:38 [error] 15003#0: *3531770 connect() failed (111: Connection refused) while connecting to upstream, client: 125.111.47.152, server: _, request: "POST /mgzapi/userOOTD/month HTTP/1.1", upstream: "http://127.0.0.1:5050/mgzapi/userOOTD/month", host: "biguden.cn:5000", referrer: "https://servicewechat.com/wxc47531ec5d63e70/devtools/page-frame.html" 2024/05/28 02:00:38 [error] 15003#0: *3531770 connect() failed (111: Connection refused) while connecting to upstream, client: 125.111.47.152, server: _, request: "GET /mgzapi/banner/opening/1/1 HTTP/1.1", upstream: "http://127.0.0.1:5050/mgzapi/banner/opening/1/1", host: "biguden.cn:5000", referrer: "https://servicewechat.com/wxc47531ec5d64e70/devtools/page-frame.html" 2024/05/28 02:00:39 [error] 15003#0: *3531770 connect() failed (111: Connection refused) while connecting to upstream, client: 125.111.47.152, server: _, request: "GET /mgzapi/wechat/getOpenid/0d3RL2s6twd4jnl2OHous0RL5l- HTTP/1.1", upstream: "http://127.0.0.1:5050/mgzapi/wechat/getOpenid/0d3RL2s6twdjiynl2OHous0RL5l-", host: "biguden.cn:5000", referrer: "https://servicewechat.com/wxc47531ec5d6370/devtools/page-frame.html" pm2 show www "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20240927/d6de921a3d0b2be9a0d7521e00780b35.png) 求解,万谢
项目使用 nuxt2 写的, 现在进行了 npm run build 打包, 想在生产环境中使用docker部署,部署方式如下 上传项目 将打包后的 .nuxt , static , nuxt.config.js , package.json , node_modules 上传至服务器 /home/wwwroot/default 下 (nginx等的配置略) 在项目目录创建启动文件 ecosystem.config.json { "apps": { "name": "web", "cwd": "/home/node", "script": "./node_modules/nuxt/bin/nuxt.js", "args": "-c /home/node/nuxt.config.js", "exec_mode": "cluster", "instances": 4, "watch":false, "error_file": "/home/logs/web-err.log", "out_file": "/home/logs/web-out.log", "log_date_format": "YYYY-MM-DD HH:mm:ss", "autorestart": true, "max_memory_restart": "500M" } } 一. 使用node镜像构建 直接基于拉取的node:16.14.0镜像运行一个容器 $ docker pull node:16.14.0 $ docker run -itd --name nuxtProject01 \ -p 3000:3000 \ -v /home/wwwroot/default:/home/node \ -v /home/logs:/home/logs node:16.14.0 然后进入容器内 $ docker exec -it nuxtProject01 bash 安装pm2 $ npm install pm2 -g 进入容器项目目录并执行ecosystem.config.json $ cd /home/node && pm2 start ecosystem.config.json 项目可以正常运行 二. 现在使用Dockerfile的方式 Dockerfile文件: FROM node:16.14.0 RUN npm config set registry https://registry.npm.taobao.org RUN npm install pm2@5.2.0 -g WORKDIR /home/node ENV NODE_ENV=production ENV HOST 0.0.0.0 EXPOSE 3000 CMD ["pm2-runtime", "start", "ecosystem.config.json"] 使用该 Dockerfile 构建自定义镜像: $ docker build --no-cache -t nuxtImage:v1.0 . 基于镜像运行一个容器: $ docker run -itd --name nuxtProject01 \ -p 3000:3000 \ -v /home/wwwroot/default:/home/node \ -v /home/logs:/home/logs nuxtImage:v1.0 现在访问服务,有以下报错: No build files found in /home/node/ecosystem.config.json/.nuxt/dist/server. 02:09:50 Use either `nuxt build` or `builder.build()` or start nuxt in development mode. Use either `nuxt build` or `builder.build()` or start nuxt in development mode. at VueRenderer._ready (node_modules/@nuxt/vue-renderer/dist/vue-renderer.js:4219:13) at async Server.ready (node_modules/@nuxt/server/dist/server.js:637:5) at async Nuxt._init (node_modules/@nuxt/core/dist/core.js:720:7) ✖ Nuxt Fatal Error │ │ │ │ Error: No build files found in /home/node/ecosystem.config.json/.nuxt/dist/server. │ │ Use either `nuxt build` or `builder.build()` or start nuxt in development mode. 找不到原因头疼