views:

50

answers:

1
+1  A: 

RVM comes with a handy wrapper generator that creates an intermediary loader for an init.d script. This allows you to load a service using a particular Ruby version and gemset. I use it like this (after installing the thin gem):

create init.d entry for thin

sudo thin install 

set up some defaults

sudo /usr/sbin/update-rc.d -f thin default 

generate boot config for your rails app

sudo thin config -C /etc/thin/<appname>.yml -c /var/rails/<appdir> --servers 4 -e production

generate rvm wrapper script

rvm wrapper <rubyversion>@<gemset> bootup thin

edit thin init

sudo nano /etc/init.d/thin

change the original loader

DAEMON=/usr/local/rvm/gems/ruby-<rubyversion>-<rubyrevision>@<gemset>/bin/thin

to point to the rvm wrapper instead

DAEMON=/usr/local/bin/bootup_thin

start it up

sudo service thin start

If you're running more than one app, just generate a boot config yml file for each one; when booting thin all yml files in /etc/thin/ are parsed. More info here:

http://wiki.rubyonrails.org/deployment/nginx-thin

HTH

Ola Tuvesson
Thanks for the reply! I ended up going the root route in the original project, but I'll use this method instead next time!
Rob Cameron