Search code examples
ruby-on-railswebserverthin

What is the best way to start thin in a rails application?


You can start the thin server by one of the following ways:

  • thin start
  • rails s (if you have thin in the Gemfile)

Is there any difference on performance/compatibility between these two ways, or the rails s actually only calls thin start?


Solution

  • It seems that they are both functionally equivalent. However, adding thin to your Gemfile will only start thin automatically if you are using rails >= 3.2. Otherwise, you will have to start thin by passing rails server thin at the command line.

    $ thin start
    >> Using rack adapter
    >> Thin web server (v1.5.1 codename Straight Razor)
    >> Maximum connections set to 1024
    >> Listening on 0.0.0.0:3000, CTRL+C to stop
    

    Notice the difference between thin start and rails server if rails >= 3.2 or rails server thin

    $ rails server thin
    => Booting Thin
    => Rails 3.2.13 application starting in development on http://0.0.0.0:3000
    => Call with -d to detach
    => Ctrl-C to shutdown server
    >> Thin web server (v1.5.1 codename Straight Razor)
    >> Maximum connections set to 1024
    >> Listening on 0.0.0.0:3000, CTRL+C to stop
    

    It prints out more info about the rails environment. It seems that sticking to the rails server convention would be the wise thing to do. Although I haven't seen anything different between the two ways of starting thin, I would stick with the conventional rails server