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
2010-07-31 04:25:31