Ceci est une ancienne révision du document !
Gunicorn
Installation
Installer gunicorn avec Pip.
Script de lancement
Configurer un script pour lancer Gunicorn:
#!/bin/bash set -e LOGFILE=/var/log/gunicorn/plateforme_web.log LOGDIR=$(dirname $LOGFILE) LOGLEVEL=warning # debug; info ou warning une fois l'installation OK NUM_WORKERS=13 # Règle : (2 x $num_cores) + 1 # user/group to run as USER=rsr # root nécessaire pour lancer sur le port 80 GROUP=rsr cd /home/rsr/plateformeduturfu source venv/bin/activate # Cette ligne ne sert que si vous utilisez virtualenv test -d $LOGDIR || mkdir -p $LOGDIR exec gunicorn -w $NUM_WORKERS \ --user=$USER --group=$GROUP --log-level=$LOGLEVEL \ --log-file=$LOGFILE 2>>$LOGFILE -b 0.0.0.0:80 application:app
Dans le cas de Django, on remplace application:app par <dossier contenant wsgi.py>.wsgi.
Création d'un service
Créer un service pour (re)lancer Gunicorn en cas de problème:
[Unit] Description=Launch gunicorn to run web plateform [Service] Type=simple User=root ExecStart=/home/user/app/start_gunicorn.sh Restart=on-failure [Install] WantedBy=multi-user.target