benoitc/gunicorn — pull request #487 by urbaniak (2013-02-19 23:01:15+00:00)
Title: systemd socket activation

Look for LISTEN_PID and LISTEN_FDS in environment, if pid is matching os.getpid() bind to number of sockets passed as LISTEN_FDS.

To test it add following systemd configuration files like that:

gunicorn.service:
```
[Unit]
Description=gunicorn daemon

[Service]
User=urban
WorkingDirectory=/home/gunicorn/bin
ExecStart=/home/urban/gunicorn/bin/gunicorn --debug --log-level debug test:app

[Install]
WantedBy=multi-user.target
```
gunicorn.socket:
```
[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/unicorn.sock
ListenStream=0.0.0.0:9000
ListenStream=[::]:8000

[Install]
WantedBy=sockets.target
```

After running `curl http://localhost:9000/` gunicorn should start and you should see something like that in logs:

```
2013-02-19 23:48:19 [31436] [DEBUG] Socket activation sockets: unix:/run/unicorn.sock,http://0.0.0.0:9000,http://[::]:8000
```