【问题标题】:Problem with Gatsby app deployment on herokuHeroku 上的 Gatsby 应用程序部署问题
【发布时间】:2021-09-23 13:44:12
【问题描述】:

我在 Heroku 上部署投资组合时遇到问题。我阅读了有关 Stack Overflow 的多篇文章、教程和答案,但仍然无法解决我的问题。

这是我的package.json

{
  "name": "my-website",
  "version": "1.0.0",
  "private": true,
  "description": "Daniel Rolewski's personal website.",
  "author": "DanielRolewski",
  "keywords": [
    "gatsby"
  ],
  "engines": {
    "node": "14.15.1",
    "npm": "6.14.8"
  },
  "buildpacks": [
    {
      "url": "heroku/nodejs"
    },
    {
      "url": "https://github.com/heroku/heroku-buildpack-static"
    }
  ],
  "scripts": {
    "build": "gatsby build",
    "start": "gatsby develop -p 5000"
  },
  "dependencies": {
    "classnames": "^2.2.6",
    "gatsby": "^2.30.2",
    "gatsby-image": "^2.9.0",
    "gatsby-plugin-alias-imports": "^1.0.5",
    "gatsby-plugin-react-helmet": "^3.7.0",
    "gatsby-plugin-sass": "^2.8.0",
    "gatsby-plugin-sharp": "^2.12.1",
    "gatsby-source-filesystem": "^2.9.0",
    "gatsby-transformer-sharp": "^2.10.1",
    "gsap": "^3.6.0",
    "node-sass": "^4.14.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-helmet": "^6.1.0",
    "typewriter-effect": "^2.17.0"
  }
}

还有我的heroku logs

2021-07-14T14:49:02.111197+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-07-14T14:49:02.196230+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-07-14T14:49:02.358675+00:00 heroku[web.1]: Process exited with status 137
2021-07-14T14:49:02.572895+00:00 heroku[web.1]: State changed from starting to crashed
2021-07-14T14:49:03.913083+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=danielrolewski-portfolio.herokuapp.com request_id=d82d115e-6694-423a-b781-fa5f17ea994c fwd="176.221.123.233" dyno= connect= service= status=503 bytes= protocol=https
2021-07-14T14:49:04.759144+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=danielrolewski-portfolio.herokuapp.com request_id=20d739d5-b2e3-45ee-ac19-24fe81a39c1c fwd="176.221.123.233" dyno= connect= service= status=503 bytes= protocol=http
2021-07-14T14:49:04.925571+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=danielrolewski-portfolio.herokuapp.com request_id=6e13f76f-b6ae-4d58-a988-d28283eec6c5 fwd="176.221.123.233" dyno= connect= service= status=503 bytes= protocol=http

更改后: "start": "gatsby develop -p 5000" 到: "start": "gatsby serve"

我有:

2021-07-14T15:15:27.903302+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-07-14T15:15:27.952418+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-07-14T15:15:28.080741+00:00 heroku[web.1]: Process exited with status 137
2021-07-14T15:15:28.172552+00:00 heroku[web.1]: State changed from starting to crashed
2021-07-14T15:15:29.648616+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=danielrolewski-portfolio.herokuapp.com request_id=5a31bb31-bcda-4048-9f21-05654e6cba75 fwd="176.221.123.233" dyno= connect= service= status=503 bytes= protocol=http
2021-07-14T15:15:29.748779+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=danielrolewski-portfolio.herokuapp.com request_id=ab0ee939-a3c1-4895-aac6-5df07f8df0ab fwd="176.221.123.233" dyno= connect= service= status=503 bytes= protocol=https
2021-07-14T15:15:29.807695+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=danielrolewski-portfolio.herokuapp.com request_id=c4c82eb5-2782-42c7-8edc-d2d5d65aab84 fwd="176.221.123.233" dyno= connect= service= status=503 bytes= protocol=http

我尝试了多种方法,但都没有奏效。请问有什么想法吗?

【问题讨论】:

  • Web process failed to bind to $PORT within 60 seconds of launch - 你明确设置了-p 5000,所以它忽略了 Heroku 试图将其绑定到的端口。此外,您可能根本不应该在生产中使用 gatsby develop
  • 感谢您的快速回复!我已经将package.json "start" 更改为:"start": "gatsby serve" 但后来我在heroku logs: pastebin.com/vsGdwytQ
  • edit 提供最新的minimal reproducible example 您的问题。
  • 仍然没有使用提供的 PORT。

标签: reactjs heroku deployment gatsby package.json


【解决方案1】:

我已经解决了!我实际上什么都没做,在 30 次相同的部署后它工作正常。

【讨论】:

    猜你喜欢
    • 2018-11-19
    • 2019-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-07
    • 2019-08-03
    • 1970-01-01
    • 2015-02-25
    相关资源
    最近更新 更多