[Mongrel] Monit + Mongrel woes

Joey Geiger jgeiger at gmail.com
Mon Mar 26 17:05:51 EDT 2007


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
>


More information about the Mongrel-users mailing list