On our production servers we use the Unicorn application server together with RVM and nginx to serve our Rails sites. This means that we need an init script for each application in case of a server restart.
Since we’re using RVM we have each unicorn process run under an unprivileged user (imaginatively named ‘unicorn’).
We use the following (Debian/Ubuntu) init script as a basis for our application init scripts, adapt it to your own needs (it’s based off another unicorn init script which did not utilise RVM).
Add the script to
/etc/init.d/APP_NAME and run the following commands to get it to run on boot:
sudo chmod +x /etc/init.d/APP_NAME sudo update-rc.d APP_NAME defaults
And that should do it…