[Zope] Perl daemon to restart hung Zope on RedHat

Michel Pelletier michel@digicool.com
Fri, 29 Jun 2001 22:22:03 -0700 (PDT)


On Fri, 29 Jun 2001, Dunigan, Craig wrote:

> > I don't use it since Zope 2.1.6, because I've not experienced any hang
> > since this date. However I've just looked at the code and I can't
> > see anything which would prevent it from being run in the background:
> >
> > 	isdazope.py [options] &
> >
> > I don't know how to really daemonize it, though.
> >
> > bye,
> >
> > Jerome Alet
> >
>
> As I'm sure you know, but for the benefit of others who might not,
> backgrounding it still needs an open console to run, and that is what I
> wanted to avoid.  Oh well, maybe someone who knows about making a Python
> daemon could step in at this point and save us?

It's no different than daemonizing any unix program.  Check out the
Stevens' book for informaiton on how to do it in C.  The methods transport
right over to python.  If I remember, setsid is important to the whole
operation after you fork.  Or something.

Zope already runs as a deamon, although it doesn't do monitoring.  When
you run z2.py, Zope splits into two processes, a parent and a child.  If
the child *exits* with an error code, the parent will restart it.  This
doesn't help hangs.

But if you look inside lib/python/zdaemon.py you'll see a 'heartbeat()'
method with some stuff commented out.  This is a heartbeat mechanism that
we wrote into zdaemon.py.  The parent process can 'kick' the child
with an http request over time intervals.  Probably nobody knows about it
except me. ;)

You can rewrite the heartbeat() function to restart the child on certain
errors.  In fact, this part of Zope was meant to do whta you guys are
doing, so if you actually finish it for me I'll check it in.

-Michel