# Will monit start my mongrel\_cluster?

**URL:** <https://www.ruby-forum.com/t/will-monit-start-my-mongrel-cluster/114649>\
**Category:** Deployment\
**Created:** [September 17, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/will-monit-start-my-mongrel-cluster/114649 "2007-09-17T13:23:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Nichols](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/65b543/32.png) [@Thomas\_Nichols](https://www.ruby-forum.com/u/Thomas_Nichols)\
**Post date:** [September 17, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/will-monit-start-my-mongrel-cluster/114649/1 "2007-09-17T13:23:37Z")

</div>

Hi,

I’m not sure if this would be better for the monit list – but this  
seems specifically a monit+mongrel\_cluster problem, so I’m hoping  
someone here may have seen this before. I’m having problems getting  
monit to start up my mongrel\_cluster processes. When I start a mongrel  
(using --only with mongrel\_rails) from the cmdline, monit detects it  
and monitors it just fine, I can see it at as ‘Status running’ at  
[http://localhost:2812](http://localhost:2812). If I kill it, monit successfully restarts it.  
However, if no mongrels are started and I just do  
monit -g mongrel start all  
==\> /var/log/messages shows `trying to restart` and then `failed to start`.

The cmdline is exactly the same as the ‘start program’ value in monitrc.

Is this as expected? Do I need to start up my mongrels with explicit  
mongrel\_rails calls, and thereafter have monit restart them if they  
fail? I’d hoped I could get to manage initial startup through monit as  
well, keep config as DRY as possible with just a mongrel\_cluster.yml and  
a monitrc. Is this possible?

Or should I be getting the pack running initially with  
/etc/init.d/mongrel\_cluster and /etc/mongrel\_cluster/\* symlinks, and  
then letting monit take over?

And then I can start on getting a script/spin that’ll work with cap  
deploy:start …

Thanks for your attention - any feedback welcome.

– Thomas.

==== /etc/monitrc ====  
set daemon 20  
set logfile syslog facility log\_daemon

# FIXME! set alert removed\_email\_address@domain.invalid

set mailserver localhost  
set mail-format { from: removed\_email\_address@domain.invalid }  
set httpd port 2812 and use address localhost  
allow localhost # Allow localhost to connect  
allow admin:foo # Allow Basic Auth  
include /etc/monit.d/\*.monitrc

==== /etc/monit.d/mongrel\_5000.monitrc – from Ezra Z.’  
excellent version [ez-monitrc](http://www.mail-archive.com/removed_email_address@domain.invalid/msg03321.html) ====

check process mongrel\_harvest\_5000  
with pidfile /var/run/mongrel\_cluster/mongrel\_harvest.5000.pid  
start program = “/usr/bin/mongrel\_rails cluster::start --only 5000  
–clean -C /var/www/rails/harvest/current/config/cluster\_harvest.yml”  
stop program = “/usr/bin/mongrel\_rails cluster::stop --only 5000  
–clean -C /var/www/rails/harvest/current/config/cluster\_harvest.yml”  
if totalmem is greater than 110.0 MB for 4 cycles then  
restart # eating up memory?  
if cpu is greater than 50% for 2 cycles then  
alert # send an email to admin  
if cpu is greater than 80% for 3 cycles then  
restart # hung process?  
if loadavg(5min) greater than 10 for 8 cycles then  
restart # bad, bad, bad  
if 20 restarts within 20 cycles then  
timeout # something is wrong, call the sys-admin  
if failed port 5000 protocol http # check for  
response  
with timeout 10 seconds  
for 2 cycles  
then restart  
group mongrel

==== cluster\_harvest.yml ====

* * *

user: mongrel  
log\_file: /var/log/mongrel/production\_harvest.log  
port: “5000”  
environment: production  
group: mongrel  
address: 127.0.0.1  
pid\_file: /var/run/mongrel\_cluster/mongrel\_harvest.pid  
servers: 3
