OCS Solutions Web Hosting Design and Consulting Web Hosting and Consulting Call Us
OCS Home  |  Wiki Front Page  |  Web Hosting  |  Virtual Dedicated Servers  |  Consulting  |  Support  |  Contact Us

Managing Your Mongrel

From OCS Support Wiki

Jump to: navigation, search

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 restart method won't work. Just run killall -9 ruby dispatch.fcgi dispatch.cgi to 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).

Personal tools