[Zope-Coders] extra-clean shutdown, signal handling

Toby Dickenson tdickenson@geminidataloggers.com
Mon, 4 Nov 2002 12:17:52 +0000


On Thursday 31 October 2002 3:49 pm, Guido van Rossum wrote:

> Alternatively, daemonizing should be done by a shell-level utility,
> instead of trying to build it in.  I'd be happy (in fact, happier) if
> we had an interface where if you said
>
>   python ZEO/start.py <options>
>
> it ran in the foreground and there was a separate tool
>
>   daemonize python ZEO/start.py <options>
>
> that ran its arguments as a daemon.

For the last few days I have been looking at running Zope under the=20
'daemontools' package from http://cr.yp.to/daemontools.html. I *thought* =
it=20
could do something similar to what Guido was suggesting.

It turns out that this package is missing a few pieces of our puzzle. It=20
doesnt handle the double-fork dance, because it expects itself to be run=20
under init. If not run under init it needs another external script to=20
redirect stdin from /dev/null.

However there are several things that this approach does do well:

* the supervisory program creates a socket which is used by a management =
tool=20
for checking status, sending signals, and bringing the daemon up and down=
=20
(without needing to stop the supervisor). This is a nice way to work.

* it avoid the race conditions I described a few weeks ago, using some se=
lect=20
trickery.=20

* Starting the process interactively and as a daemon can now use an ident=
ical=20
command line, which makes it easier to stuff it into a start script and=20
forget about it.


Overall, +1 for this approach.