[英]Heroku with Docker - ERROR H14:No web processes running
I'm trying to deploy a simple nodejs app served in express and Pm2, via a Docker container on Heroku.我正在尝试通过 Heroku 上的 Docker 容器在 express 和 Pm2 中部署一个简单的 nodejs 应用程序。
Following the steps defined by heroku, the container is sucessfully pushed to heroku:按照heroku定义的步骤,容器成功推送到heroku:
Here is the log of heroku showing the success on running the image and assigning a dyno to the process Container Deployment Log这是 heroku 的日志,显示成功运行映像并将测功机分配给进程容器部署日志
Here is when the problem comes: while accessing to the apps routes the Heroku H14 Error is throw, which happens when a proccess doesn't have Dynos, which in my case it have.这是问题出现的时候:在访问应用程序路由时,会抛出 Heroku H14 错误,当进程没有 Dynos 时会发生这种情况,在我的情况下它有。 Error H14 Log错误 H14 日志
I'm out of ideas as the reason this error is raising.我没有想法作为此错误引发的原因。 I know it might be a silly mistake thought XD!!我知道这可能是一个愚蠢的错误想 XD !
Here you got the code for my app:在这里你得到了我的应用程序的代码:
const express = require('express')
const app = express()
//require('./database')
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
console.log('App is Running, yaaaay')
app.get("/", (req,res) => {
res.send("OK")
})
app.listen(3000)
and its run with Pm2:并与 Pm2 一起运行:
"scripts": {
"dev": "nodemon ./src/app",
"start": "pm2-runtime ./src/app.js --watch --name WD-Bot"
},
Also, here you got my DockerFile.另外,这里有我的 DockerFile。 I'm pretty newbie on Docker, so i probably messed up on here TT?我是 Docker 的新手,所以我可能在这里搞砸了 TT?
FROM node:12.18-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
You did:你做了:
heroku container:push name-of-container -a name-of-herokuApp
You assume that's the name of the container.您假设这是容器的名称。 That's wrong.那是错误的。 As per https://devcenter.heroku.com/articles/container-registry-and-runtime#build-an-image-and-push that's the process type:根据https://devcenter.heroku.com/articles/container-registry-and-runtime#build-an-image-and-push ,这是流程类型:
heroku container:push <process-type>
The error message you are receiving is:您收到的错误消息是:
ERROR H14:No web processes running
You named your process wd-bot
and not web
.您将进程命名为wd-bot
而不是web
。
After changing your process type to web
you'll have to properly bind the $PORT
as well.将进程类型更改为web
后,您还必须正确绑定$PORT
。 See: https://help.heroku.com/P1AVPANS/why-is-my-node-js-app-crashing-with-an-r10-error请参阅: https://help.heroku.com/P1AVPANS/why-is-my-node-js-app-crashing-with-an-r10-error
But that's a different topic and is a new question.但这是一个不同的话题,是一个新问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.