[Web-SIG] Starting Web Servers using socket FDs

Tarek Ziadé tarek at ziade.org
Tue Jun 5 14:00:45 CEST 2012


On 6/5/12 1:56 PM, Roberto De Ioris wrote:
>>> uWSGI supports by-default the inheritance of file descriptor 0 for fcgi-like startup,
>>> and working on generic file descriptor or inet/upstart/systemd socket activation.
>> I did not find a way to start it using a provided fd -- they are plethora of options though, maybe I missed it
>
> it is automatic if the fd is the zero one, otherwise you have to "authenticate" it adding a --socket/--http-socket/--fastcgi-socket directive
> mapping to the address (this is required for avoiding uWSGI inheriting unrelated sockets, like the ones created by ssh-agents and whatever you want).
>
> For example if you map fd 17 to 192.168.1.1:4040 you have to run uwsgi with
>
> --socket 192.168.1.1:4040
>
> it will find fd 17 mapped to a socket, and it will know the socket is authorized to be used.
>
> Other components take the special fd://<n>  syntax (like the various routers) but i do not think you are intersted in them

Great, thanks, will try this

>
>
>>> The vast majority of modern systems expects the file descriptor number on an environment variable:
>>>
>>> upstart: UPSTART_FDS
>>> systemd: LISTEN_FDS
>> Yes, this seem fairly standard.
>>> Circus, could follow the same behaviour, but i do not know if a standard will be required for that.
>> The goal of the standard is just to be able to place any wsgi server out there and have it working out of the box.
> if this is your objective i suggest you to follow the inetd/fastcgi style approach and use file descriptor 0 as the communication socket.
> Flup and uWSGI will work over this automatically. Gunicorn will work simply adding GUNICORN_FD=0
>
> Adding another env-var will mean each server will need to add a condition for that (like upstart and systemd)
The thing is, the main process might bind several sockets, and have 
various subprocesses linked to specific ones, so I guess the uWsgi --socket
approach is the most straightforward

Thanks for all the info

> --
> Roberto De Ioris
> http://unbit.it
> JID: roberto at jabber.unbit.it
>



More information about the Web-SIG mailing list