Starting Rails apps on server's reboot

Hello list,

I’ve got a server with several Rails application running under mongrel. It works fine, but the problem is when I reboot it. Having to go to each app’s dir and restart mongrel is a pain, so I would like to know if there’s already something (maybe a rake task or bash script) that solves this problem? If not, what would be the recommended way? A bash script?

Thanks in advance.

Use whatever mechanism your OS uses for other services, likely an rc script.

Pat

Pat, thanks for the reply.

So basically I should add to the script a line to start mongrel for each Rails app I have on the server?

I use @reboot in cron:

@reboot cd /www/eq2guild/guildcorner/current && ./script/spin @reboot cd /www/blog/flame-blog/current && ./script/spin ...

That starts the tasks as a user I choose (in my case, the user is named 'webtoys') and since cron starts very late in the OS boot process, things will generally be well up and running before my application starts.

Note that if you put them in an rc script, they might run as root unless you specifically ask them them not to. And then what happens if you mess up that file? Will the system still boot?

Running things in a crontab also has the advantage that anyone who can run the crontab command can set it up -- no special root privs needed.

--Michael

Hi Marcelo

In the Win2003 server environment, just set each mongrel service to start automatically.

CCH

On Linux systems, aren't daemon tools or runit a more attractive option? These have the added benefit of restarting Mongrel whenever it stops, regardless of the reason. I used to have this working using mongrel_cluster, but I haven't had it working right since switching to Capistrano 2.1. Cap2.1 doesn't support the mongrel_cluster gem, and I haven't fully figured out everything necessary to make it work again.

I also have a backgroundrb task to restart.

Anyone have the magic for runit?