id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,uname,nginx_version 237,Add optional systemd socket activation support,David Strauss,somebody,"The systemd project supports socket activation for services, allowing systemd to listen on the socket initially. When the first connection comes in, systemd starts the service and passes in any listening sockets as file descriptors. The following patch, which is ready for general implementation review, adds support with a --with-system configuration option. When this support is compiled in, nginx can use ""listen fd:3"" (and other numbers) to specify that a given nginx server should use the inherited file descriptor in lieu of opening its own socket. The implementation initializes nginx's data structures with (mostly) the same information that would generally be derived from the configured listener. For example, nginx will know the listening IP address and port of an INET or INET6 socket. Why nginx benefits from this: * systemd can listen on privileged ports or socket paths and start nginx with privileges already dropped. This is good for shared/multitenant environments where user configuration of nginx is offered. * Virtually no memory or CPU is in use until nginx receives the first request. There is a ~20ms overhead for the first request while nginx starts. It is also possible with systemd socket activation to start nginx by default, before any request has come in. * Any service in front of nginx doesn't have to wait for nginx to finish starting (or start at all) before sending in the first request. This is useful for setups where something like Varnish is in front of nginx. * Major upgrades or reconfigurations of nginx requiring a full restart are possible without having the listening socket(s) ever go away. If nginx does a clean shutdown (without killing any requests), it's possible to have zero requests fail and no service interruption from the nginx restart. Known TODOs or possible changes needed in the implementation: * Obviously, logging and printf calls need cleanup. * Unix sockets don't initialize the path as the address name. They list the ""fd:N"" string. This doesn't affect functionality, but it might be nice to fix. * No documentation updates made yet.",enhancement,reopened,minor,,nginx-core,1.3.x,,,,Linux athena 3.6.2-4.fc17.x86_64 #1 SMP Wed Oct 17 02:43:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux,"nginx version: nginx/1.3.8 built by gcc 4.7.2 20120921 (Red Hat 4.7.2-2) (GCC) configure arguments: --with-systemd --with-ipv6"