[Web-SIG] Starting Web Servers using socket FDs

Tarek Ziadé tarek at ziade.org
Tue Jun 5 11:30:37 CEST 2012


Hey

I am doing this experimentation where the WGSI server is not started 
with an host/port or a unix socket, but rather a FD value,
corresponding to a socket already bound by the parent process.

The server would then just accept new connection on the FD, using 
socket.fromfd() to get a socket object back,
and forget about all the binding work.

Here's a prototype based on wsgiref : 
https://github.com/tarekziade/chaussette

The goal I have is to be able to just spawn web workers using subprocess 
and take care myself  of the process
management part.  I wrote a blog post on my motivations here : 
http://blog.ziade.org/2012/06/12/shared-sockets-in-circus
if you want more background.

Anyways, the idea I wanted to bring here was the following:

most web servers out there support regular host/port or Unix Socket, 
which are usually the "unix:" prefix followed by a path on the system.

What if web servers had these two standards *and* a new one which would 
be a "fd:" prefix.

For instance, we would start server foo with:

$ foo --fd:12:localhost:8080

Where 12 is the fd number the foo server would use for getting the 
socket, and "localhost:8080" would just be there
as an information to be able to fill some WGSI headers that requires it.

 From there I could just spawn "foo" and pass to it socket.fileno()

Thoughts ?

Cheers
Tarek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/web-sig/attachments/20120605/493b5448/attachment.html>


More information about the Web-SIG mailing list