【问题标题】:Deploying sinatra app (with config.ru) on heroku cedar stack在 heroku cedar 堆栈上部署 sinatra 应用程序(使用 config.ru)
【发布时间】:2012-01-10 13:46:57
【问题描述】:

我正在尝试使用this response 的一些提示重构我的 sinatra 代码以将我的主文件分成单独的文件,但我在部署到 heroku 时遇到了麻烦。

以前我没有config.ru 文件,只是使用了我的Procfile,即:

web: bundle exec ruby web.rb -p $PORT

根据this article

通过重构,我现在将Procfile 更改为

web: bundle exec thin -R config.ru start -p $PORT

有了我的config.ru 文件

root = ::File.dirname(__FILE__)
require ::File.join( root, 'web' )
run MyApp.new

我的 web.rb 文件包含在类定义中

class MyApp < Sinatra::Application
  # ...
end

这适用于我的本地开发计算机,但是当我部署到 heroku 时,我得到了

2011-12-01T11:21:54+00:00 app[web.1]: bundler: command not found: thin
2011-12-01T11:21:54+00:00 app[web.1]: Install missing gem executables with `bundle install`
2011-12-01T11:21:56+00:00 heroku[web.1]: State changed from starting to crashed
2011-12-01T11:22:01+00:00 heroku[router]: Error H10 (App crashed) -> GET [my app].herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2011-12-01T11:22:02+00:00 heroku[router]: Error H10 (App crashed) -> GET [my app].herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=

heroku 上没有安装 Thin 吗?或者是否有其他方法可以通过更改在 heroku 上运行我的应用程序?

【问题讨论】:

    标签: ruby deployment heroku sinatra


    【解决方案1】:

    我不得不更新我的Procfile,因为RACK_ENV 没有传递到heroku 环境中。 Procfile 变成了:

    web: bundle exec thin -R config.ru start -p $PORT -e $RACK_ENV
    

    【讨论】:

    • 好的,所以我根本不需要更改 config.ru 来使用 Sinatra::Application 而不是 MyApp.new。从答案中删除它。
    猜你喜欢
    • 2011-12-08
    • 2012-04-11
    • 1970-01-01
    • 2017-03-09
    • 1970-01-01
    • 2020-03-13
    • 2019-04-16
    • 2018-11-08
    相关资源
    最近更新 更多