Managing Your Mongrel
From OCS Support Wiki
Contents |
Introduction
This guide will show you how to restart your Mongrel, and if desired, use cron to automatically restart it.
Restarting Mongrel
Run the following commands via SSH:
cd ~/rails_sites/yourapp mongrel_rails restart
Replace rails_sites/yourapp with the location of your Rails application.
Problems Restarting Your Mongrel
If you see an error message similar to this:
!!! PID file log/mongrel.pid does not exist. Not running? mongrel::restart reported an error. Use mongrel_rails mongrel::restart -h to get help.
Then please check the following:
- Are you using Mongrel? If you're using Lighttpd, FastCGI, or CGI mode, the
mongrel_rails restartmethod won't work. Just runkillall -9 ruby dispatch.fcgi dispatch.cgito restart your FastCGI application. - Your Mongrel may not be running. Start the mongrel with the usual start command you use (i.e.
mongrel_rails start -e production -p 60000 -d).
Using Cron to Automatically Restart Mongrel
On both cPanel and Webmin, you can use cron to schedule an automatic restart of your Mongrel. To do so, via SSH, run:
crontab -e
You'll be presented with an editor (usually nano) to edit your cron jobs. Add the line:
@daily cd ~/rails_sites/yourapp ; mongrel_rails restart
to it, replacing rails_sites/yourapp with the path to your Rails application. You can change @daily to @hourly if your Rails app needs to be restarted more frequently.
Don't forget to exit and save the file to apply the changes (in nano, press CTRL+X, hit enter, and this will save and exit).
