How to use Thin effectivly

Apr 22, 2011 • Jordan Hollinger

Thin is a super-cool Rack app server written in Ruby. Normally you’ll run it behind a Webserver like Apache or Nginx. It’s great and I use it for most of my Rails and Sinatra Web apps. But my goals isn’t to convert you (like I was converted from Passenger). My goals is to tell you how to use it effectively in production.

That’s great for testing and development, but not for deployment. Fortunately Thin has some great options, but unfortunately it took hours of searching to find them. So here they are, all in one place. All of the following assumes you’ve already installed Thin with

gem install thin

are generally comfortable with it, and are running as root or sudo-ing.

Start your Thins on system boot

thin install

You’ll see output like the following. This will boot all your configured Thin apps every time your system starts. Or, on Debian/Ubuntu for instance, you could run /etc/init.d/thin stop|start|restart at any time.

Configure your Thins

Place config files for all the Thin apps you want auto-started into /etc/thin/ . They’ll be YAML files, so their extentions should be .yml. Here’s an example with lots, but not all, available options. I have yet to find a comprehensive list, but they’re mostly the same as the command-line options listed by thin -h .

Stop/restart individual apps

Maybe it’s obvious to you, but it wasn’t to me. For a long time, if I wanted to restart one of my apps, all I knew to do was restart them all with /etc/init.d/thin restart . Eventually I figured out how to do it one at a time with