Heroku部署Node失败code=H10 heroku Process exited with status State changed from up to crashed

2021-06-05T10:15:58.729523+00:00 app[web.1]: [egg-scripts] Wait Start: 6...
2021-06-05T10:15:59.745250+00:00 app[web.1]: [egg-scripts] Wait Start: 7...
2021-06-05T10:16:00.042515+00:00 heroku[web.1]: State changed from starting to up
2021-06-05T10:16:00.771824+00:00 app[web.1]: [egg-scripts] Wait Start: 8...
2021-06-05T10:16:01.683843+00:00 app[web.1]: [egg-scripts] egg started on http://127.0.0.1:51422
2021-06-05T10:16:01.768141+00:00 heroku[web.1]: Process exited with status 0
2021-06-05T10:16:01.823385+00:00 heroku[web.1]: State changed from up to crashed
2021-06-05T10:16:01.832850+00:00 heroku[web.1]: State changed from crashed to starting
2021-06-05T10:16:06.424438+00:00 heroku[web.1]: Starting process with command `npm start`
2021-06-05T10:16:10.538383+00:00 app[web.1]:
2021-06-05T10:16:10.538409+00:00 app[web.1]: > feelingcard@1.0.0 start /app
2021-06-05T10:16:10.538410+00:00 app[web.1]: > egg-scripts start --daemon --title=egg-server-egg
2021-06-05T10:16:10.538410+00:00 app[web.1]:
2021-06-05T10:16:11.030291+00:00 app[web.1]: [egg-scripts] Starting egg application at /app
2021-06-05T10:16:11.030320+00:00 app[web.1]: [egg-scripts] Run node /app/node_modules/egg-scripts/lib/start-cluster {"title":"egg-server-egg","port":"55982","baseDir":"/app","framework":"/app/node_modules/egg"} --title=egg-server-egg
2021-06-05T10:16:11.030321+00:00 app[web.1]: [egg-scripts] Save log file to /app/logs
2021-06-05T10:16:12.060797+00:00 app[web.1]: [egg-scripts] Wait Start: 1...
2021-06-05T10:16:13.070041+00:00 app[web.1]: [egg-scripts] Wait Start: 2...
2021-06-05T10:16:14.087121+00:00 app[web.1]: [egg-scripts] Wait Start: 3...
2021-06-05T10:16:15.108051+00:00 app[web.1]: [egg-scripts] Wait Start: 4...
2021-06-05T10:16:16.113289+00:00 app[web.1]: [egg-scripts] Wait Start: 5...
2021-06-05T10:16:17.124159+00:00 app[web.1]: [egg-scripts] Wait Start: 6...
2021-06-05T10:16:18.127574+00:00 app[web.1]: [egg-scripts] Wait Start: 7...
2021-06-05T10:16:19.175277+00:00 app[web.1]: [egg-scripts] Wait Start: 8...
2021-06-05T10:16:19.442908+00:00 heroku[web.1]: State changed from starting to up
2021-06-05T10:16:20.183218+00:00 app[web.1]: [egg-scripts] Wait Start: 9...
2021-06-05T10:16:21.192451+00:00 app[web.1]: [egg-scripts] Wait Start: 10...
2021-06-05T10:16:21.415040+00:00 app[web.1]: [egg-scripts] egg started on http://127.0.0.1:55982
2021-06-05T10:16:21.616497+00:00 heroku[web.1]: Process exited with status 0
2021-06-05T10:16:21.679110+00:00 heroku[web.1]: State changed from up to crashed
2021-06-05T10:21:53.266659+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=feelingcard.herokuapp.com request_id=f9ed7ff8-e91c-4528-a907-4e14deb20348 fwd="42.87.141.185" dyno= connect= service= status=503 bytes= protocol=https
2021-06-05T10:21:53.515240+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=feelingcard.herokuapp.com request_id=ec7c09f3-1f8d-4338-936c-0aa90d314e54 fwd="42.87.141.185" dyno= connect= service= status=503 bytes= protocol=https
2021-06-05T10:21:54.342294+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=feelingcard.herokuapp.com request_id=ae28018c-88d2-4569-ac1a-d89b4631c802 fwd="42.87.141.185" dyno= connect= service= status=503 bytes= protocol=https
  1. Bug in Procfile     配置文件空格
    A very interesting discovery for me. A bug in your Procfile can crash your app. If your Procfile is pointing to the wrong server file. e.g If your server is in server.js and your Procfile points to app.js this would definitely crash your app and Heroku would greet you with the H10-App crashed error code message.
    Secondly, a buggy Procfile can also come in the form of wrong spacing. e.g
    Wrong: web : node index.js
    Correct web: node index.js

    对我来说,这是一个非常有趣的发现。一个 bug 在你的 Procfile 可以崩溃你的应用程序。如果您的 Procfile 指向错误的服务器文件。例如,如果你的服务器在 server.js 中,而你的 Procfile 指向 app.js,这肯定会使你的应用崩溃,Heroku 会用 H10-App 崩溃的错误代码消息来问候你。其次,错误的 Procfile 也可能以错误的间距的形式出现。错误: web: node index.js Correct web: node index.js

  2. Setting a PORT as a Heroku environment variable  不指定端口
    This would surely crash your app. Heroku automatically sets a Port that can be accessed via process.env.PORT. Setting a port yourself would crash your app. Surprisingly, the command heroku config does not display the preset Heroku port so one might be tempted to set another port as an environment variable.
    To see all the preset Heroku environment variables, use the command heroku run printenv.

    将 PORT 设置为 Heroku/环境变量这肯定会让你的应用崩溃。Heroku 自动设置一个端口,可以通过 process.env.Port 访问该端口。自己设置一个端口会让你的应用崩溃。令人惊讶的是,Heroku config 命令没有显示预设的 Heroku 端口,所以人们可能会把另一个端口设置为环境变量端口。要查看所有预设置的 Heroku 环境变量,使用 Heroku run printenv 命令。

  3. Missing Required Environment Variable while setting a port would cause this error because Heroku already sets a port internally, failing to set any required environment variable (e.g your database), would prompt Heroku to greet you with this error.

    在设置端口时丢失所需的环境变量将导致此错误,因为 Heroku 已经在内部设置了一个端口,但是没有设置任何所需的环境变量(例如数据库) ,这将提示 Heroku 以此错误向您致意。

  4. Missing Required Scripts
    This error is thrown in a Node.js environment if you forget to set a start script. Heroku uses this script to start your app so if it is missing, it would throw an H10-App crashed error code message.

    缺少必需的脚本如果您忘记设置开始脚本,这个错误会在 Node.js 环境中抛出。Heroku 使用这个脚本启动应用程序,因此如果丢失应用程序,它将抛出一个 H10-App 崩溃错误代码消息。


package.json

"scripts": {
    "start": "egg-scripts start --daemon --title=egg-server-egg",
    "stop": "egg-scripts stop --title=egg-server-egg",
    "dev": "egg-bin dev",
    "debug": "egg-bin debug",
    "test": "npm run lint -- --fix && npm run test-local",
    "test-local": "egg-bin test",
    "cov": "egg-bin cov",
    "lint": "eslint .",
    "ci": "npm run lint && npm run cov",
    "autod": "autod",
    "build": "npm install --production"
  },

项目是eggjs,最后删掉了start的  --daemon 才部署成功 

之前应该是后台进程被杀掉了导致的反复部署成功又失败

--daemon: 是否允许在后台模式,无需 nohup。若使用 Docker 建议直接前台运行。

 

 

Causes of Heroku H10-App Crashed Error And How To Solve Them - DEV Community

Heroku Error Codes | Heroku Dev Center

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值