HowtoDjango: ajouter Gunicorn
This commit is contained in:
parent
6ef843cb91
commit
81a6cb71e8
|
@ -339,3 +339,54 @@ $ source bin/activate
|
||||||
(lib)$ easy_install -U Django
|
(lib)$ easy_install -U Django
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
## Gunicorn
|
||||||
|
|
||||||
|
Gunicorn est un service WSGI qui peut être intégré avec Django. Le service peut être géré avec systemd. On définira deux fichiers :
|
||||||
|
|
||||||
|
* `/etc/systemd/system/gunicorn.service`
|
||||||
|
|
||||||
|
~~~
|
||||||
|
[Unit]
|
||||||
|
Description=gunicorn daemon
|
||||||
|
Requires=gunicorn.socket
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=mon_user
|
||||||
|
Group=www-data
|
||||||
|
WorkingDirectory=/chemin/vers/mon_env
|
||||||
|
ExecStart=/chemin/vers/mon_env/venv/bin/gunicorn \
|
||||||
|
--access-logfile /var/log/gunicorn.log \
|
||||||
|
--workers 4 \
|
||||||
|
--bind unix:/run/gunicorn.sock \
|
||||||
|
mon_env.wsgi:application
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
~~~
|
||||||
|
|
||||||
|
* `/etc/systemd/system/gunicorn.socket`
|
||||||
|
|
||||||
|
~~~
|
||||||
|
[Unit]
|
||||||
|
Description=gunicorn socket
|
||||||
|
|
||||||
|
[Socket]
|
||||||
|
ListenStream=/run/gunicorn.sock
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sockets.target
|
||||||
|
~~~
|
||||||
|
|
||||||
|
* Dans son _vhost_ Nginx :
|
||||||
|
|
||||||
|
~~~
|
||||||
|
server {
|
||||||
|
[…]
|
||||||
|
location / {
|
||||||
|
include proxy_params;
|
||||||
|
proxy_pass http://unix:/run/gunicorn.sock;
|
||||||
|
}
|
||||||
|
[…]
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
Loading…
Reference in a new issue