Topic: Rails Reboot Script


I am starting to write my first Rails application using Rails 3.0.0.   I am at the point where I have uploaded the application to my host and have everything working as I want.  I am now trying to put together a script to start my server in the case where my host reboots the server.

I have put together the following shell script which I will execute on reboot via crontab - once its working!
#! /bin/sh
cd /home/userXXX/apps/wedding && rvm use 1.9.2 && thin start -e production -p 1300 -d

This script works great when I run it from my application directory /home/userXXX/apps/wedding

When I run the script from anywhere I get an error:
>> Writing PID to tmp/pids/
>> Using rack adapter
Could not find activesupport-3.0.0 in any of the sources
Try running `bundle install`.

This is likely as much a Unix issue as a Rails issue since it seems like the script is running the 'thin start' command from the wrong directory, even though I am changing to the correct directory.

Any direction you can provide would be much appreciated by this newbie.  Thanks!

Re: Rails Reboot Script

If you do a thin -h, you'll see --chdir (or -c) and with this option, you can pass in your working directory.

rvm use 1.9.2 && thin start -e production -p 1300 -c /home/userXXX/apps/wedding -d

Re: Rails Reboot Script

I had contacted my host and they correct an error in the script.  The updated script was:

cd /home/userXXXXX/apps/wedding &&
                source /usr/local/rvm/scripts/rvm &&
                source .rvmrc &&
                /usr/local/rvm/gems/ruby-1.9.2-p0/bin/thin start -p 13700 -d -a

It has been working well but if I run into any issues I will try your suggestion.