How to set Thin as default in Rails 3
Asked Answered
A

4

34

I've been starting Thin with thin -V start in development.

However, I would like Thin to be the default instead of WEBrick and to be able to start it with rails s.

Is there a way to set Thin as the default instead of WEBrick in Rails 3?

If that's not possible, is there at least a way to start it in the test environment automatically?

Auger answered 12/8, 2011 at 23:49 Comment(1)
Add gem 'thin' to your Gemfile and see if that works?Superjacent
N
46

I sent a pull request on the Github repository of rack and it was accepted: https://github.com/rack/rack/commit/b487f02b13f42c5933aa42193ed4e1c0b90382d7

In a near future, we will be able to use Thin just by adding gem 'thin' to our Gemfile and starting app with rails s.

Note that this may be a temporary measure, however.

I chose Thin because Mongrel was not maintained currently and no other server seemed to suit as an alternative to Mongrel.

Nonparticipating answered 27/12, 2011 at 21:35 Comment(3)
As of Rails 3.2.0.rc2, which was released yesterday, rails s invokes Thin when your Gemfile has gem 'thin' line. Yey!Nonparticipating
Actually, rails s now invokes Thin even if we attempt to set WEBrick as the development default with gem 'webrick', group: :development. I'm using Ruby 1.9.3-p327 and Rails 3.2.12 on Debian, BTW.Limousin
@Limousin You are right. This has been the behavior of rack since the era of mongrel. If you have installed the first-priority server library (currently, thin), the rack picks it up instead of WEBrick even if Gemfile does not contain gem 'thin'.Nonparticipating
S
14

Alternatively you could use foreman, especially if your web applications tend to get more complicated to run (background workers, clock processes to handle scheduling, etc.)

Taking thin as an example, you would need to create a Procfile in your Rails app with the following content:

web: bundle exec rails server thin -p $PORT

Then just:

foreman start

to start your server.

Skiest answered 13/8, 2011 at 14:54 Comment(0)
V
8

You can run rails3 with thin using rails server thin

See the output of rails server -h for more options.

Valparaiso answered 12/8, 2011 at 23:57 Comment(3)
it's still more typing than just rails s, but I like it.Calvary
you can use alias to short itCousingerman
@LukeCowell you can still use rails s thinAchaemenid
V
4

In Gem file use: gem 'thin'
bundle install
then rails s it will take thin as default server for your project.

Valorievalorization answered 21/8, 2012 at 5:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.