gpt4 book ai didi

node.js - 如何将我的 Node js 应用程序(实时跟踪)部署到 heroku

转载 作者:太空宇宙 更新时间:2023-11-04 01:53:23 27 4
gpt4 key购买 nike

我尝试将 Node js 应用程序部署到 Heroku。但总是出现应用程序错误..

这是我的网络日志

2018-02-19T09:00:51.759639+00:00 heroku[web.1]: State changed from crashed to starting 2018-02-19T09:00:54.029447+00:00 heroku[web.1]: Starting process with command node index.js 2018-02-19T09:00:55.992998+00:00 app[web.1]: server started on port 3000 2018-02-19T09:01:54.487612+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2018-02-19T09:01:54.487612+00:00 heroku[web.1]: Stopping process with SIGKILL 2018-02-19T09:01:54.622011+00:00 heroku[web.1]: State changed from starting to crashed 2018-02-19T09:01:54.608384+00:00 heroku[web.1]: Process exited with status 137

在我的终端中,它警告没有找到 env 文件

这是更新的日志..

2018-02-20T22:33:28.164758+00:00 app[web.1]: at Module._compile (module.js:570:32) 2018-02-20T22:33:28.164760+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10) 2018-02-20T22:33:28.164761+00:00 app[web.1]: at Module.load (module.js:487:32) 2018-02-20T22:33:28.164763+00:00 app[web.1]: at tryModuleLoad (module.js:446:12) 2018-02-20T22:33:28.164765+00:00 app[web.1]: at Function.Module._load (module.js:438:3) 2018-02-20T22:33:28.164766+00:00 app[web.1]: at Module.runMain (module.js:604:10) 2018-02-20T22:33:28.164768+00:00 app[web.1]: at run (bootstrap_node.js:389:7) 2018-02-20T22:33:28.164769+00:00 app[web.1]: at startup (bootstrap_node.js:149:9) 2018-02-20T22:33:28.164771+00:00 app[web.1]: at bootstrap_node.js:504:3 2018-02-20T22:33:41.623294+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=realtime-tracker.herokuapp.com request_id=f5ccc5ea-8044-454e-95d5-9175b93a4be3 fwd="110.54.168.160" dyno= connect= service= status=503 bytes= protocol=https 2018-02-20T22:33:42.405421+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=realtime-tracker.herokuapp.com request_id=9a88d409-6292-4361-b6ca-057e8b8fd5ad fwd="110.54.168.160" dyno= connect= service= status=503 bytes= protocol=https Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect... 2018-02-20T22:33:28.164758+00:00 app[web.1]: at Module._compile (module.js:570:32) 2018-02-20T22:33:28.164760+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10) 2018-02-20T22:33:28.164761+00:00 app[web.1]: at Module.load (module.js:487:32) 2018-02-20T22:33:28.164763+00:00 app[web.1]: at tryModuleLoad (module.js:446:12) 2018-02-20T22:33:28.164765+00:00 app[web.1]: at Function.Module._load (module.js:438:3) 2018-02-20T22:33:28.164766+00:00 app[web.1]: at Module.runMain (module.js:604:10) 2018-02-20T22:33:28.164768+00:00 app[web.1]: at run (bootstrap_node.js:389:7) 2018-02-20T22:33:28.164769+00:00 app[web.1]: at startup (bootstrap_node.js:149:9) 2018-02-20T22:33:28.164771+00:00 app[web.1]: at bootstrap_node.js:504:3 2018-02-20T22:33:41.623294+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=realtime-tracker.herokuapp.com request_id=f5ccc5ea-8044-454e-95d5-9175b93a4be3 fwd="110.54.168.160" dyno= connect= service= status=503 bytes= protocol=https 2018-02-20T22:33:42.405421+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=realtime-tracker.herokuapp.com request_id=9a88d409-6292-4361-b6ca-057e8b8fd5ad fwd="110.54.168.160" dyno= connect= service= status=503 bytes= protocol=https Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect... 2018-02-20T22:33:28.164758+00:00 app[web.1]: at Module._compile (module.js:570:32) 2018-02-20T22:33:28.164760+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10) 2018-02-20T22:33:28.164761+00:00 app[web.1]: at Module.load (module.js:487:32) 2018-02-20T22:33:28.164763+00:00 app[web.1]: at tryModuleLoad (module.js:446:12) 2018-02-20T22:33:28.164765+00:00 app[web.1]: at Function.Module._load (module.js:438:3) 2018-02-20T22:33:28.164766+00:00 app[web.1]: at Module.runMain (module.js:604:10) 2018-02-20T22:33:28.164768+00:00 app[web.1]: at run (bootstrap_node.js:389:7) 2018-02-20T22:33:28.164769+00:00 app[web.1]: at startup (bootstrap_node.js:149:9) 2018-02-20T22:33:28.164771+00:00 app[web.1]: at bootstrap_node.js:504:3 2018-02-20T22:33:41.623294+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=realtime-tracker.herokuapp.com request_id=f5ccc5ea-8044-454e-95d5-9175b93a4be3 fwd="110.54.168.160" dyno= connect= service= status=503 bytes= protocol=https 2018-02-20T22:33:42.405421+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=realtime-tracker.herokuapp.com request_id=9a88d409-6292-4361-b6ca-057e8b8fd5ad fwd="110.54.168.160" dyno= connect= service= status=503 bytes= protocol=https

最佳答案

Heroku 动态地为您分配一个端口作为环境变量 (PORT)。不要尝试强制监听特定端口,而是使用:

listen(process.env.PORT)

关于node.js - 如何将我的 Node js 应用程序(实时跟踪)部署到 heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48862516/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com