【问题标题】:Heroku, Thin and everything in betweenHeroku、Thin 以及介于两者之间的一切
【发布时间】:2011-12-24 16:16:00
【问题描述】:

查看日志,我的 cedar 应用程序当前运行 webrick。显然,这不是生产应用的最佳选择。

正如网络上所说的,我应该使用瘦网络服务器。

但我仍然想在我的开发机器(windows)上使用 webrick 的简单性。

正如Heroku cedar stack, thin and eventmachine 上的 cmets 中所述,可以在 windows 上为 eventmachine 安装的版本(我还需要对该 gem 进行一些解释)是 1.0.0.beta4,heroku 不喜欢这样。

  1. 如何仅在 heroku 上安装 Thin(我猜是 eventmachine)并保留 webrick 以满足我的所有 localhost 需求?

  2. 什么是 eventmachine,我为什么需要它?

  3. 有没有办法明确告诉heroku忽略我想要的并使用thin?

【问题讨论】:

  • 要仅在生产中使用瘦,您需要在 Gemfile group :production do; gem 'thin'; end 中声明它并将其放入 Procfile:web: bundle exec rails server thin -p $PORT,如 devcenter.heroku.com/articles/rails3 中所述
  • Heroku recommends Unicorn 现在用于生产应用程序

标签: ruby-on-rails-3 heroku thin webrick


【解决方案1】:

在您的Gemfile 中,创建或更改production 组以包含thin

group :production do
  gem 'thin'  
end

然后,在您的 Procfile一个名为 Procfile 的文件放置在您的应用的根目录中)中,告诉 Heroku 您要使用 thin,如下所示:

web: bundle exec thin start -p $PORT

这将允许您在本地开发环境中继续使用 Webrick,同时在 Heroku 上的生产环境中运行 thin

【讨论】:

  • 我正在用 Rails 3.2.21 做同样的事情,但它说:bundler: failed to load command: thin (/app/vendor/bundle/ruby/2.2.0/bin/thin)
【解决方案2】:

要跳过在本地机器上安装 thin gem,请像这样调用 bundler:

bundle install --without production

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-11
    • 1970-01-01
    • 2016-11-06
    • 2021-05-25
    • 2018-02-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多