代码之家  ›  专栏  ›  技术社区  ›  JGallardo anglimasS

尝试将gatsby站点部署到heroku时出现应用程序错误

  •  0
  • JGallardo anglimasS  · 技术社区  · 6 年前

    预期结果

    我应该可以看到我的博客(与盖茨比一起构建)部署到heroku的url http://vllg.herokuapp.com/

    实际结果

    页面显示一个错误,指示我检查日志,下面是结果。

    enter image description here

    原木

    2019-03-13T21:41:28.488417+00:00 app[web.1]: success createPages — 0.066 s
    2019-03-13T21:41:28.539587+00:00 app[web.1]: success createPagesStatefully — 0.051 s
    2019-03-13T21:41:28.542875+00:00 app[web.1]: success onPreExtractQueries — 0.003 s
    2019-03-13T21:41:28.856797+00:00 app[web.1]: success update schema — 0.314 s
    2019-03-13T21:41:28.917320+00:00 app[web.1]: warning Using the global `graphql` tag is deprecated, and will not be supported in v3.
    2019-03-13T21:41:28.917324+00:00 app[web.1]: Import it instead like:  import { graphql } from 'gatsby' in file:
    2019-03-13T21:41:28.917326+00:00 app[web.1]: /app/src/pages/blog.js
    2019-03-13T21:41:28.999695+00:00 app[web.1]: success extract queries from components — 0.143 s
    2019-03-13T21:41:29.155426+00:00 app[web.1]: success run graphql queries — 0.156 s — 10/10 64.94 queries/second
    2019-03-13T21:41:29.159995+00:00 app[web.1]: success write out page data — 0.004 s
    2019-03-13T21:41:29.160825+00:00 app[web.1]: success write out redirect data — 0.001 s
    2019-03-13T21:41:29.362576+00:00 app[web.1]: done generating icons for manifest
    2019-03-13T21:41:29.363187+00:00 app[web.1]: success onPostBootstrap — 0.202 s
    2019-03-13T21:41:29.363362+00:00 app[web.1]:
    2019-03-13T21:41:29.363506+00:00 app[web.1]: info bootstrap finished - 6.089 s
    2019-03-13T21:41:29.363561+00:00 app[web.1]:
    2019-03-13T21:41:35.474922+00:00 app[web.1]: DONE  Compiled successfully in 4713ms9:41:35 PM
    2019-03-13T21:41:35.475029+00:00 app[web.1]:
    2019-03-13T21:41:35.488519+00:00 app[web.1]:
    2019-03-13T21:41:35.488812+00:00 app[web.1]: You can now view vllg in the browser.
    2019-03-13T21:41:35.488882+00:00 app[web.1]:
    2019-03-13T21:41:35.488935+00:00 app[web.1]: http://localhost:8000/
    2019-03-13T21:41:35.489000+00:00 app[web.1]:
    2019-03-13T21:41:35.489074+00:00 app[web.1]: View GraphiQL, an in-browser IDE, to explore your site's data and schema
    2019-03-13T21:41:35.489139+00:00 app[web.1]:
    2019-03-13T21:41:35.489197+00:00 app[web.1]: http://localhost:8000/___graphql
    2019-03-13T21:41:35.489246+00:00 app[web.1]:
    2019-03-13T21:41:35.489329+00:00 app[web.1]: Note that the development build is not optimized.
    2019-03-13T21:41:35.489406+00:00 app[web.1]: To create a production build, use npm run build
    2019-03-13T21:41:35.489460+00:00 app[web.1]:
    2019-03-13T21:41:35.518813+00:00 app[web.1]: ℹ 「wdm」:
    2019-03-13T21:41:35.518919+00:00 app[web.1]: ℹ 「wdm」: Compiled successfully.
    2019-03-13T21:42:21.505858+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
    2019-03-13T21:42:21.505911+00:00 heroku[web.1]: Stopping process with SIGKILL
    2019-03-13T21:42:21.660871+00:00 heroku[web.1]: State changed from starting to crashed
    2019-03-13T21:42:21.643794+00:00 heroku[web.1]: Process exited with status 137
    2019-03-14T03:25:18.012932+00:00 heroku[web.1]: State changed from crashed to starting
    2019-03-14T03:25:26.974905+00:00 heroku[web.1]: Starting process with command `npm start`
    2019-03-14T03:25:29.221439+00:00 app[web.1]:
    2019-03-14T03:25:29.221465+00:00 app[web.1]: > vllg@0.1.0 start /app
    2019-03-14T03:25:29.221467+00:00 app[web.1]: > npm run develop
    2019-03-14T03:25:29.221469+00:00 app[web.1]:
    2019-03-14T03:25:29.642388+00:00 app[web.1]:
    2019-03-14T03:25:29.642437+00:00 app[web.1]: > vllg@0.1.0 develop /app
    2019-03-14T03:25:29.642951+00:00 app[web.1]: > gatsby develop
    2019-03-14T03:25:29.642954+00:00 app[web.1]:
    2019-03-14T03:25:34.179104+00:00 app[web.1]: lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory
    2019-03-14T03:25:34.371576+00:00 app[web.1]: success open and validate gatsby-configs — 0.018 s
    2019-03-14T03:25:35.101757+00:00 app[web.1]: success load plugins — 0.729 s
    2019-03-14T03:25:36.254992+00:00 app[web.1]: success onPreInit — 1.153 s
    2019-03-14T03:25:36.301769+00:00 app[web.1]: success delete html and css files from previous builds — 0.047 s
    2019-03-14T03:25:36.341230+00:00 app[web.1]: success initialize cache — 0.039 s
    2019-03-14T03:25:36.394596+00:00 app[web.1]: success copy gatsby files — 0.053 s
    2019-03-14T03:25:36.405920+00:00 app[web.1]: success onPreBootstrap — 0.011 s
    2019-03-14T03:25:36.570578+00:00 app[web.1]: success source and transform nodes — 0.165 s
    2019-03-14T03:25:37.534865+00:00 app[web.1]: success building schema — 0.964 s
    2019-03-14T03:25:37.682403+00:00 app[web.1]: success createPages — 0.145 s
    2019-03-14T03:25:37.846729+00:00 app[web.1]: success createPagesStatefully — 0.164 s
    2019-03-14T03:25:37.856984+00:00 app[web.1]: success onPreExtractQueries — 0.010 s
    2019-03-14T03:25:38.258545+00:00 app[web.1]: success update schema — 0.401 s
    2019-03-14T03:25:38.381310+00:00 app[web.1]: warning Using the global `graphql` tag is deprecated, and will not be supported in v3.
    2019-03-14T03:25:38.381315+00:00 app[web.1]: Import it instead like:  import { graphql } from 'gatsby' in file:
    2019-03-14T03:25:38.381317+00:00 app[web.1]: /app/src/pages/blog.js
    2019-03-14T03:25:38.546084+00:00 app[web.1]: success extract queries from components — 0.287 s
    2019-03-14T03:25:38.877403+00:00 app[web.1]: success run graphql queries — 0.331 s — 10/10 30.74 queries/second
    2019-03-14T03:25:38.888429+00:00 app[web.1]: success write out page data — 0.011 s
    2019-03-14T03:25:38.889427+00:00 app[web.1]: success write out redirect data — 0.001 s
    2019-03-14T03:25:39.394941+00:00 app[web.1]: done generating icons for manifest
    2019-03-14T03:25:39.397600+00:00 app[web.1]: success onPostBootstrap — 0.508 s
    2019-03-14T03:25:39.398607+00:00 app[web.1]:
    2019-03-14T03:25:39.399205+00:00 app[web.1]: info bootstrap finished - 9.734 s
    2019-03-14T03:25:39.399508+00:00 app[web.1]:
    2019-03-14T03:25:49.598021+00:00 app[web.1]: DONE  Compiled successfully in 7982ms3:25:49 AM
    2019-03-14T03:25:49.598123+00:00 app[web.1]:
    2019-03-14T03:25:49.668957+00:00 app[web.1]:
    2019-03-14T03:25:49.669051+00:00 app[web.1]: You can now view vllg in the browser.
    2019-03-14T03:25:49.669113+00:00 app[web.1]:
    2019-03-14T03:25:49.669181+00:00 app[web.1]: http://localhost:8000/
    2019-03-14T03:25:49.669263+00:00 app[web.1]:
    2019-03-14T03:25:49.669509+00:00 app[web.1]: View GraphiQL, an in-browser IDE, to explore your site's data and schema
    2019-03-14T03:25:49.669573+00:00 app[web.1]:
    2019-03-14T03:25:49.669642+00:00 app[web.1]: http://localhost:8000/___graphql
    2019-03-14T03:25:49.669711+00:00 app[web.1]:
    2019-03-14T03:25:49.669766+00:00 app[web.1]: Note that the development build is not optimized.
    2019-03-14T03:25:49.669875+00:00 app[web.1]: To create a production build, use npm run build
    2019-03-14T03:25:49.669941+00:00 app[web.1]:
    2019-03-14T03:25:49.809865+00:00 app[web.1]: ℹ 「wdm」:
    2019-03-14T03:25:49.810002+00:00 app[web.1]: ℹ 「wdm」: Compiled successfully.
    2019-03-14T03:26:27.415495+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
    2019-03-14T03:26:27.415791+00:00 heroku[web.1]: Stopping process with SIGKILL
    2019-03-14T03:26:27.640591+00:00 heroku[web.1]: Process exited with status 137
    2019-03-14T03:26:27.669848+00:00 heroku[web.1]: State changed from starting to crashed
    2019-03-14T06:29:40.584512+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vllg.herokuapp.com request_id=05381bb0-3b5e-4191-b20f-bd1a0ab788fe fwd="98.164.218.149" dyno= connect= service= status=503 bytes= protocol=http
    2019-03-14T06:29:40.995063+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vllg.herokuapp.com request_id=69bc54f5-3ffc-469c-8919-7f46eef7ed3f fwd="98.164.218.149" dyno= connect= service= status=503 bytes= protocol=http
    2019-03-14T06:31:47.930409+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vllg.herokuapp.com request_id=53dd38e4-9b34-41fe-8838-2ce2f659ddc0 fwd="98.164.218.149" dyno= connect= service= status=503 bytes= protocol=http
    2019-03-14T06:31:48.205331+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vllg.herokuapp.com request_id=140a8ca7-0a44-4a91-83f7-9726a1c1a94b fwd="98.164.218.149" dyno= connect= service= status=503 bytes= protocol=http
    2019-03-14T06:50:31.151053+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vllg.herokuapp.com request_id=4aef2e8c-d00e-4fc6-9d72-f05fe676a7b1 fwd="98.164.218.149" dyno= connect= service= status=503 bytes= protocol=http
    2019-03-14T06:50:31.476418+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vllg.herokuapp.com request_id=af2c772d-3299-4767-8c7b-e2fa0de414ab fwd="98.164.218.149" dyno= connect= service= status=503 bytes= protocol=http
    2019-03-14T06:52:49.412131+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vllg.herokuapp.com request_id=84f885b2-a2d7-42c5-a4ff-8b9f2d692c39 fwd="98.164.218.149" dyno= connect= service= status=503 bytes= protocol=http
    2019-03-14T06:52:49.675993+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vllg.herokuapp.com request_id=23679509-eff5-46c2-86e6-1971c91dc368 fwd="98.164.218.149" dyno= connect= service= status=503 bytes= protocol=http
    

    回购协议

    我的代码库可在 https://github.com/JGallardo/vllg


    尝试的解决方案和研究

    • 我在 Heroku "Process exited with status 137" node.js app 但不知道该如何应用到我的项目中
    • 我看到需要生成生产生成的错误?在我所遵循的教程中,heroku的说明中没有提到,但是我运行了 npm run build 并且看不到新的生成文件夹。
    • 我也看到有一个r 10错误,我在 Heroku Boot Timeout (Error R10) 但这似乎是一个python项目,因为我认为procfile只适用于ruby项目?

    0 回复  |  直到 6 年前
        1
  •  2
  •   MarceDev    6 年前

    我以前没用过Heroku,但我可以给你一些指导,也许可以看看你的日志。

    gatsby develop 应该是只在测试站点时才使用的一个开发命令,因此看起来它有冲突,尽管您无论如何都不应该使用该命令,因为它应该使用 gatsby build . 使用 Gatsby develop 也不提供一个优化版本的网站,所以你错过了许多好处。

    那说 盖茨比建筑 使用静态资源在目录中创建公用文件夹。对于本地测试,您应该使用 gatsby serve 以正确查看生成并确保其按预期工作。对于heroku,不必使用serve命令,只需将静态资产放在public文件夹中即可。

    你也可以按照本指南“教”Heroku如何为你构建。 https://www.gatsbyjs.org/docs/deploying-to-heroku/

    也可以确认netlify对于静态站点和gatsby来说是非常棒的。

        2
  •  0
  •   soywod Ronnie Smith    6 年前

    heroku对于服务器端应用程序更有用。有了命令 build ,盖茨比为您提供了博客的静态版本。这样,你就可以把它上传到一个CDN上,这样性能就更好了。我建议 Netlify :

    • 它是免费的
    • 基于你的github帐户
    • 它会自动部署新的更改(通过git提交挂钩)
    • 你甚至可以使用自定义域
    推荐文章