10

Looking at the logs, my cedar app currently runs webrick. Obviously, this is not the best choice for production app.

As noted all over the web, I should use Thin webserver.

But I would still like to use the simplicty of webrick on my development machine (windows).

As noted in the comments on Heroku cedar stack, thin and eventmachine the version that can be installed on windows for eventmachine (I also need some explanation on that gem) is 1.0.0.beta4 and heroku doesn't like that..

  1. How do I install thin (and eventmachine I guess) only on heroku and keep webrick for all my localhost needs?

  2. What is eventmachine and why do I need it?

  3. Is there a way to explicitly tell heroku to ignore what I want and use thin?

Community
  • 1
  • 1
Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
  • 1
    To use thin only in production you will need declare this in Gemfile `group :production do; gem 'thin'; end` and put this into Procfile: `web: bundle exec rails server thin -p $PORT` as described in http://devcenter.heroku.com/articles/rails3 – taro Dec 24 '11 at 20:15
  • Heroku [recommends Unicorn](https://devcenter.heroku.com/articles/getting-started-with-rails4#webserver) for production apps now – Yarin Jan 28 '14 at 18:14

2 Answers2

30

In your Gemfile, create or change the production group to include thin:

group :production do
  gem 'thin'  
end

Then, in your Procfile (a file named Procfile placed in the root of your app), tell Heroku you want to use thin, like so:

web: bundle exec thin start -p $PORT

That will allow you to keep using Webrick in your local development environment while running thin in production on Heroku.

user664833
  • 18,397
  • 19
  • 91
  • 140
leonardoborges
  • 5,579
  • 1
  • 24
  • 26
  • I'm doing the exact same thing, with Rails `3.2.21`, but it says: `bundler: failed to load command: thin (/app/vendor/bundle/ruby/2.2.0/bin/thin)` – Arslan Ali Aug 13 '17 at 04:24
0

In order to skip installation of thin gem on your local machine, call bundler like this:

bundle install --without production
Viktor
  • 2,982
  • 27
  • 32