python:gunicorn

Ceci est une ancienne révision du document !


Gunicorn

Source

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

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
  • python/gunicorn.1547660446.txt.gz
  • Dernière modification : 2021/04/04 17:01
  • (modification externe)