/ / Setup gunicorn per eseguire con Django - python, django, gunicorn

Imposta gunicorn per correre con Django - python, django, gunicorn

Ho installato gunicorn e il mio progetto di Django kb quando scrivo kb e corri gunicorn --bind 0.0.0.0:8000 kb.wsgi:application funziona bene.

Ho corso nano su /etc/init/gunicorn.conf

description "Gunicorn application server handling myproject"

start on runlevel [2345]
stop on runlevel [!2345]


respawn
setuid user
setgid www-data
chdir /home/ubuntu/kb

exec gunicorn --workers 3 --bind unix:/home/ubuntu/kb/kb.sock kb.wsgi:application

Quando corro sudo service gunicorn start

ottengo Failed to start gunicorn.service: Unit gunicorn.service not found.

AGGIORNARE

La linea exec:

exec gunicorn --workers 3 --bind unix:/home/ubuntu/kb/kb.sock kb.wsgi:application

proviene da un esempio in cui gunicorn è installato in un virtualenv. Ho modificato il exec virtualenvbingunicorn a exec gunicorn

risposte:

0 per risposta № 1

Invece di usare gunicorn.conf meglio usare il file qui sotto ....

sudo nano /etc/systemd/system/gunicorn.service

Aggiungi le impostazioni di conf di seguito in questo file ....

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=dj
Group=www-data
WorkingDirectory=/home/dj/myproject
ExecStart=/home/dj/myproject/myprojectenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/dj/myproject/myproject.sock myproject.wsgi:app$

[Install]
WantedBy=multi-user.target

Modifica autorizzazione alle directory ..

chmod g + x / home / dj /

chmod g + r / home / dj /

sudo chgrp www-data / home / dj /

Nota: si prega di assicurarsi che il gunicorn dovrebbe essere all'interno del virtualenv ..

Cordiali saluti: pip installare gunicorn Sotto virtualenv

Spero che questo ti aiuti .. Funziona per me ..