Starting Web Servers using socket FDs
Tarek Ziadé <tarek-A/[email protected]> Tue, 05 Jun 2012 11:30:37 +0200
| Newsgroups | gmane.comp.python.web |
|---|---|
| Message-ID | <[email protected]> |
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 _______________________________________________ Web-SIG mailing list [email protected] Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: http://mail.python.org/mailman/options/web-sig/gcpw-web-sig%40m.gmane.org