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

Guido van Rossum guido@python.org
Mon, 04 Nov 2002 14:55:49 -0500


> > 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 
> 'daemontools' package from http://cr.yp.to/daemontools.html. I *thought* it 
> could do something similar to what Guido was suggesting.
> 
> It turns out that this package is missing a few pieces of our puzzle. It 
> doesnt handle the double-fork dance, because it expects itself to be run 
> under init. If not run under init it needs another external script to 
> 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 
> for checking status, sending signals, and bringing the daemon up and down 
> (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 select 
> trickery. 
> 
> * Starting the process interactively and as a daemon can now use an identical 
> command line, which makes it easier to stuff it into a start script and 
> forget about it.
> 
> Overall, +1 for this approach.

+1 from me, too.  (Does this need to be recorded somewhere as a
programming task up for grabs?)

--Guido van Rossum (home page: http://www.python.org/~guido/)