Tuesday, September 16, 2008

Supervisord and Memmon

Three problems I've had with Plone.
  1. How to start and stop Plone instances
  2. How to deal with Plone instances that run away with memory
  3. How to restart Plone processes that have died
Number 3 was more of a problem a few years ago with older versions of Zope, more recently Zope/Plone seems to run "forever". I used to use DJB daemontools to solve these problems and I still have servers that are "supervised" by daemontools. My problem is that, although daemontools works quite well working with it feels less than organic (read: doesn't play nicely with package managers rpm, apt or easy_install).

The solution

Well I believe that I've found the solution, and it goes by the name of "Supervisord" and the fun slogan "hang on to your processes". As a bonus, it is python based, installs nicely via easy_install and newer versions of ZopeSkel's plone_hosting template now ship with a supervisord configuration.

A recipe
In short, with a few deft strokes of the keyboard, I can have my Plone and supervise it. My recipe goes something like this:

1. Get the latest ZopeSkel

easy_install ZopeSkel

2. Install Plone hosting (I'll call my directory "usain").

paster create -t plone_hosting

3. Add lines similar to this to my crontab (by running crontab -e)

@reboot /home/plone/usain/bin/supervisord -c /home/plone/usain/etc/supervisord.conf

4. For good measure add a line like this to my supervisord.conf file:
command=%(here)s/../bin/memmon -a 200MB -m bob@example.com
If any supervised processes run over 200MB of resident memory usage for more than 60 seconds, supervisor will restart them.

No comments:

Sign up for my upcoming Plone 5 Book & Video tutorials

plone 5 for newbies book and videos