Issue #532 new

Allow reuse of listener socket on UNIX

Robert Brewer
created an issue

Thought up by Joseph Tate and discussed [http://groups.google.com/group/cherrypy-devel/browse_thread/thread/a43a629ae31191ef/c34ea1b91a7db0df here] and [http://www.defuze.org/oss/cpirc/%23cherrypy.2006-05-05.log.html here]:

UNIX allows the re-use of sockets via socket.fromfd(fd). _cpwsgiserver could pass the fd from one process to another via os.environ. UNIX users could then employ signal handlers like these:

{{{

!python

def sigusr1(signum, frame): """Re-exec the process.""" cherrypy.server.stop() cherrypy.log("Re-executing %s %s" % (sys.executable, sys.argv)) os.execv(sys.executable, [sys.executable] + sys.argv)

def sigusr2(signum, frame): """Restart the HTTP server.""" cherrypy.server.restart()

signal.signal(signal.SIGUSR1, sigusr1) signal.signal(signal.SIGUSR2, sigusr2) }}}

See [1116] for an experimental implementation of the socket reuse. The signal handlers could either be stuck in /lib somewhere, or enabled by default on platforms where hasattr(signal, "SIGUSR1").

Comments (4)

  1. Anonymous

    Not a showstopper for CP3.0. Let's get it out of the roadmap for now.

    It will be interesting to have a solution in the next release however.

  2. Log in to comment