[Mongrel] Monit + Mongrel woes

Carl Lerche carl.lerche at gmail.com
Tue Mar 27 13:02:44 EDT 2007


Thanks for the suggestion. I have tried this, however it still didn't work.

I have finally figured out why it wasn't working for me. There were 2 reasons.

1) Mongrel_cluster was not dealing with directories correctly. It
would try to find the pid file in log/<pid_file> relative to where the
command was called, not the directory specified in the configuration
file.

2) My mongrel_rails command is located in /usr/local/bin and monit
specifies a "spartan" path (/bin:/usr/bin:/sbin:/usr/sbin). I hacked
this by linking /usr/bin/mongrel_rails to /usr/local/bin/mongrel_rails

-carl

On 3/27/07, Corey Donohoe <atmos at atmos.org> wrote:
> Upload your mongrel_cluster.yml here
> http://monitr.atmos.org/generators/mongrel_cluster
>
> sudo gem install mongrel_cluster --source
> http://mongrel.rubyforge.org/releases/ && gem cleanup
>
> That should get you going in the right direction.
>
>
> On 3/26/07, Carl Lerche < carl.lerche at gmail.com> wrote:
> > Hello,
> >
> > How would I tell mongrel_cluster to restart a single mongrel instance
> > (if only one of them failed? Do you have an example of a monitrc file
> > that uses mongrel_cluster?
> >
> > Thanks,
> > -carl
> >
> > On 3/26/07, Joey Geiger < jgeiger at gmail.com> wrote:
> > > If you're not using mongrel_cluster, you might want to look into using
> it.
> > >
> > > If you are, I would suggest rewriting your monit scripts to deal with
> > > the new pid file location, and such.
> > >
> > > The new mongrel_cluster can handle the leftover pid files, and will
> > > clean them up before attempting to restart.
> > >
> > > On 3/26/07, Carl Lerche < carl.lerche at gmail.com> wrote:
> > > > Hello all,
> > > >
> > > > So, I've been using monit with mongrel for a while now, since the
> > > > 0.3.x days (I think it was). It used to work fine, but now I seem to
> > > > be having some trouble. I'm currently using mongrel 1.0.1 and I am
> > > > using the same monit configuration I've always been using, yet
> > > > everytime monit should restart mongrel, I get "Execution failed".
> > > >
> > > > For the start command, I originally used the following:
> > > > ------------
> > > > start program = "/usr/bin/su admin -c '/usr/local/bin/mongrel_rails
> > > > start -d -e production -p 8001 -a 127.0.0.1 -c
> > > > /home/admin/webapps/gohuman/current -P
> log/mongrel.8001.pid'"
> > > > ------------
> > > > But then monit started giving me execution failed errors and when I
> > > > tried to run it manually I got a "PID already exists" error. So, I
> > > > tried the following:
> > > > ------------
> > > > start program = "/bin/rm -f
> > > >
> /home/admin/webapps/gohuman/shared/log/mongrel.8001.pid &&
> /usr/bin/su
> > > > admin -c '/usr/local/bin/mongrel_rails start -d -e production -p 8001
> > > > -a 127.0.0.1 -c /home/admin/webapps/gohuman/current
> -P
> > > > log/mongrel.8001.pid'"
> > > > ------------
> > > > Which just adds the rm at the start. Yet, monit still can't manage to
> > > > restart mongrel. I have no idea why. This is my full monit file
> > > >
> > > > ------------
> > > > ##### mongrel 8000 - GoHuman #####
> > > > check process mongrel-8000 with pidfile
> > > >
> /home/admin/webapps/gohuman/shared/log/mongrel.8000.pid
> > > >     start program = "/bin/rm -f
> > > >
> /home/admin/webapps/gohuman/shared/log/mongrel.8000.pid &&
> /usr/bin/su
> > > > admin -c '/usr/local/bin/mongrel_rails start -d -e production -p 8000
> > > > -a 127.0.0.1 -c /home/admin/webapps/gohuman/current
> -P
> > > > log/mongrel.8000.pid'"
> > > >     stop program  = "/usr/bin/su admin -c
> > > > '/usr/local/bin/mongrel_rails stop -c
> > > > /home/admin/webapps/gohuman/current -P
> log/mongrel.8000.pid'"
> > > >
> > > >     if totalmem is greater than 80.0 MB for 5 cycles then alert
> > > >  # 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 3 restarts within 5 cycles then timeout
> > > >  # something is wrong, call the sys-admin
> > > >
> > > >     group gohuman
> > > >
> > > > ##### mongrel 8001 - GoHuman #####
> > > > check process mongrel-8001 with pidfile
> > > >
> /home/admin/webapps/gohuman/shared/log/mongrel.8001.pid
> > > >     start program = "/bin/rm -f
> > > >
> /home/admin/webapps/gohuman/shared/log/mongrel.8001.pid &&
> /usr/bin/su
> > > > admin -c '/usr/local/bin/mongrel_rails start -d -e production -p 8001
> > > > -a 127.0.0.1 -c /home/admin/webapps/gohuman/current
> -P
> > > > log/mongrel.8001.pid'"
> > > >     stop program  = "/usr/bin/su admin -c
> > > > '/usr/local/bin/mongrel_rails stop -c
> > > > /home/admin/webapps/gohuman/current -P
> log/mongrel.8001.pid'"
> > > >
> > > >     if totalmem is greater than 80.0 MB for 5 cycles then alert
> > > >  # 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 3 restarts within 5 cycles then timeout
> > > >  # something is wrong, call the sys-admin
> > > >
> > > >     group gohuman
> > > >
> > > > ##### mongrel 8002 - GoHuman #####
> > > > check process mongrel-8002 with pidfile
> > > >
> /home/admin/webapps/gohuman/shared/log/mongrel.8002.pid
> > > >     start program = "/bin/rm -f
> > > >
> /home/admin/webapps/gohuman/shared/log/mongrel.8002.pid &&
> /usr/bin/su
> > > > admin -c '/usr/local/bin/mongrel_rails start -d -e production -p 8002
> > > > -a 127.0.0.1 -c /home/admin/webapps/gohuman/current
> -P
> > > > log/mongrel.8002.pid'"
> > > >     stop program  = "/usr/bin/su admin -c
> > > > '/usr/local/bin/mongrel_rails stop -c
> > > > /home/admin/webapps/gohuman/current -P
> log/mongrel.8002.pid'"
> > > >
> > > >     if totalmem is greater than 80.0 MB for 5 cycles then alert
> > > >  # 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 3 restarts within 5 cycles then timeout
> > > >  # something is wrong, call the sys-admin
> > > >
> > > >     group gohuman
> > > > ------------
> > > >
> > > > Thanks,
> > > > -carl
> > > > --
> > > > EPA Rating: 3000 Lines of Code / Gallon (of coffee)
> > > > _______________________________________________
> > > > Mongrel-users mailing list
> > > > Mongrel-users at rubyforge.org
> > > > http://rubyforge.org/mailman/listinfo/mongrel-users
> > > >
> > > _______________________________________________
> > > Mongrel-users mailing list
> > > Mongrel-users at rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/mongrel-users
> > >
> >
> >
> > --
> > EPA Rating: 3000 Lines of Code / Gallon (of coffee)
> > _______________________________________________
> > Mongrel-users mailing list
> > Mongrel-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/mongrel-users
> >
>
>
>
> --
> Corey Donohoe
>  http://www.atmos.org/
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users
>


-- 
EPA Rating: 3000 Lines of Code / Gallon (of coffee)


More information about the Mongrel-users mailing list