简体   繁体   English

将 sinatra 应用程序部署到 heroku 的问题

[英]problems deploying sinatra app to heroku

Ive just tried deploying a basic sinatra app to heroku and everytime i try and access the app through heroku i keep getting the following error messages in the heroku logs我刚刚尝试将一个基本的 sinatra 应用程序部署到 heroku,每次我尝试通过 heroku 访问该应用程序时,我都会在 heroku 日志中收到以下错误消息

2016-10-14T14:34:12.243266+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sleepy-fjord-82689.herokuapp.com request_id=4e85cc9f-a2e2-4dc4-bbb6-8daa9de6778b fwd="82.5.195.102" dyno= connect= service= status=503 bytes= 2016-10-14T14:34:12.243266+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sleepy-fjord-82689.herokuapp.com request_id =4e85cc9f-a2e2-4dc4-bbb6-8daa9de6778b fwd="82.5.195.102" dyno= connect= service= status=503 bytes=

2016-10-14T14:34:13.108228+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sleepy-fjord-82689.herokuapp.com request_id=c173f495-e2f9-4119-8e45-790e2f55fc6e fwd="82.5.195.102" dyno= connect= service= status=503 bytes= 2016-10-14T14:34:13.108228+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sleepy-fjord-82689.herokuapp .com request_id=c173f495-e2f9-4119-8e45-790e2f55fc6e fwd="82.5.195.102" dyno=connect=service=status=503 bytes=

Im new to heroku so I havent really got a clue why this is happening, any help pointing me in the right direction would be appreciated.我是 Heroku 的新手,所以我还没有真正知道为什么会发生这种情况,任何帮助我指向正确方向的帮助将不胜感激。

Your application is crashing when navigating to the root ('/').导航到根目录 ('/') 时,您的应用程序崩溃。 First make sure the app works on local machine, then follow the rack app guide for Heroku.首先确保应用程序可以在本地机器上运行,然后按照 Heroku 的机架应用程序指南进行操作。 There's a section for Sinatra.有一个关于 Sinatra 的部分。 If this doesn't work, makes sure you can deploy the Hello World app as shown the in the example correctly.如果这不起作用,请确保您可以正确部署 Hello World 应用程序,如示例中所示。

Can you post here your Procfile file and your config.ru please?你能在这里发布你的 Procfile 文件和你的 config.ru 吗?

if you want to check that your Procfile is working, you can check it locally with the foreman gem .如果您想检查您的 Procfile 是否正常工作,您可以使用foreman gem 在本地检查它。 Basically you need to add foreman to your development group in Gemfile and you can create a Procfile file with this content:基本上,您需要在 Gemfile 中将 foreman 添加到您的开发组,您可以使用以下内容创建 Procfile 文件:

web: bundle exec rackup -p $PORT

And start your application with command foreman start .并使用命令foreman start启动您的应用程序。

Also to show in logs the full backtrace of the error, please consider adding to your Gemfile the gem rails_12factor and make sure that is available in the production group also.还要在日志中显示错误的完整回溯,请考虑将 gem rails_12factor添加到您的rails_12factor ,并确保它在生产组中也可用。

This should allow you to see at least the full backtrace of the error.这应该能让您至少看到错误的完整回溯。 Hope this helps you.希望这对你有帮助。

Note: Sinatra does not reload the application locally upon changes.注意:Sinatra 不会根据更改在本地重新加载应用程序。 If you want that, i would suggest you to use the rerun gem and the rb-fsevent gems in your development group, and a different Procfile for the development environment.如果你想,我会建议你使用rerun创业板和rb-fsevent在你的开发小组的宝石,和不同的Procfile的发展环境。

Example: Procfile.dev web: rerun -- bundle exec rackup -p $PORT示例:Procfile.dev web: rerun -- bundle exec rackup -p $PORT : rerun web: rerun -- bundle exec rackup -p $PORT

and run it locally with foreman start -f Procfile.dev .并使用foreman start -f Procfile.dev在本地运行它。 This will allow you to change code and see the changes without manually restarting the server everytime.这将允许您更改代码并查看更改,而无需每次都手动重新启动服务器。

Hope this helps you at least find the erorr.希望这至少可以帮助您找到错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM