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?
@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.
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.