[Zope-Coders] Signal forwarding

Chris McDonough chrism@ZOPE.COM
10 Oct 2002 11:37:47 -0400


On Thu, 2002-10-10 at 11:14, Guido van Rossum wrote:
> Try to do the minimal amount of work in the handler.  I see no need to
> close sockets -- process exit will close them just fine.  The only
> thing you apparently need to do is close the storage because
> FileStorage writes the new index to disk when closed.  (Though if the
> storage is ZEO, closing the ClientStorage in Zope is unnecessary.)

I removed the socket closings a couple days ago (this was causing
ZEO-connected clients to hang at shutdown time)... so the only thing the
shutdown handler does is to close open database connections.  I hope
leaving it in there is an acceptable risk.

> I have to review the signal handlers in the ZEO storage server.  They
> are different (ZEO uses SIGINT instead of SIGHUP to ask for a restart)
> and I fear that the funny business with writing *two* pids to the
> pidfile also doesn't work as intended (not that I understand how it
> was intended).

SIGINT seems like the wrong signal for restart if you intend on running
ZEO in "debug mode" as it seems to be what gets sent on most platforms
when you press ctrl-c in the controlling terminal.

Zope now only writes one pid to the file... if Zope is started under
ZDaemon, the pid is the ZDaemon pid.  If Zope is not started under
ZDaemon, the pid is the Zope pid.  ZEO should probably doe the same.

This patch to ZEO's start.py seems to do the trick:

Index: start.py
===================================================================
RCS file: /cvs-repository/ZEO/ZEO/start.py,v
retrieving revision 1.46
diff -r1.46 start.py
219c219,228
<     if Z:
---
>     pidfile_name = env.zeo_pid
> 
>     if not Z:
>         try:
>             pid = os.getpid()
>         except:
>             pass # getpid not supported
>         else:
>             open(pidfile_name,'w').write("%s\n" % pid)
>     else:
226c235
<             zdaemon.run(sys.argv, '')
---
>             zdaemon.run(sys.argv, pidfile_name)
261,266d269
<         try:
<             ppid, pid = os.getppid(), os.getpid()
<         except:
<             pass # getpid not supported
<         else:
<             open(env.zeo_pid,'w').write("%s %s\n" % (ppid, pid))

HTH,

- C