I a*_*ser 9 javascript heroku mongodb node.js
我最近发布了一个类似主题的问题.我对URL上的所有内容进行了重大改进,并且上次发生了同样的事情:我可以部署所有内容并使用它来运行它heroku local web.当我去网络dyno,它说我有一个应用程序错误,然后我检查日志.这是它所说的(我在github上使用一个名为atwork的项目):
2017-05-02T02:35:39.191493+00:00 app[web.1]: Loaded model: chats.js
2017-05-02T02:35:39.200517+00:00 app[web.1]: Loaded model: streams.js
2017-05-02T02:35:39.196830+00:00 app[web.1]: Loaded model: posts.js
2017-05-02T02:35:39.209761+00:00 app[web.1]: Loaded model: users.js
2017-05-02T02:35:40.067321+00:00 app[web.1]: AtWork running at http://:::8111
2017-05-02T02:35:50.116492+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=room111-thoughts.herokuapp.com request_id=44a6e779-e6b8-4a33-a5b9-53430af2ad8f fwd="108.221.62.78" dyno= connect= service= status=503 bytes= protocol=https
2017-05-02T02:36:35.859814+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-05-02T02:36:35.859903+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-05-02T02:36:35.956564+00:00 heroku[web.1]: Process exited with status 137
2017-05-02T02:36:35.969766+00:00 heroku[web.1]: State changed from starting to crashed
2017-05-02T02:37:22.933285+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=room111-thoughts.herokuapp.com request_id=80ffc71f-d792-4538-b50a-5140b7658819 fwd="108.221.62.78" dyno= connect= service= status=503 bytes= protocol=https
Run Code Online (Sandbox Code Playgroud)
我是Heroku和Node.js的初学者,所以任何帮助都表示赞赏.我将提供寻找答案所需的任何信息.
che*_*hxx 10
我检查了日志,它说at=error code=H10 desc="App crashed",这意味着你有uncaught Exception,所以你应该检查你的代码.
如果你想mongodb在Heroku 上使用,你应该尝试添加mongodb addon你的应用程序.你可以在这里找到这份文件
并尝试使用process.env.PORT,而不是您想要使用的端口.
如果它仍然没有解决您的问题,您可以尝试使用此命令heroku run bash,此命令可以使您进入heroku环境并启动您的服务器.
我在 heroku 上托管 Node 应用程序时遇到了同样的错误,结果是端口问题,所以只需将端口设置为等于这个
var port = process.env.PORT || 8080;
Run Code Online (Sandbox Code Playgroud)
所以 process.env.PORT || 8080 表示:环境变量 PORT 中的任何内容,如果没有,则为 8080。
然后在下面设置set port变量
var server=app.listen(port,function() {
console.log("app running on port 8080"); });
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12437 次 |
| 最近记录: |