Conas Django a úsáid le UWSgiLink to this heading

uWSGI is freastalaí coimeádán feidhmchláir thapa, féin-leighis agus cairdiúil don fhorbróir/sysadmin atá códaithe i C íon.

Réamhriachtanas: UwsGiLink to this heading

Déanann wiki UwsGi cur síos ar roinnt nósanna imeachta suiteálaí. Ag baint úsáide as pip, bainisteoir pacáiste Python, is féidir leat aon leagan uwsGi a shuiteáil le hordú amháin. Mar shampla:

Shell
# Install current stable version.
$ python -m pip install uwsgi

# Or install LTS (long term support).
$ python -m pip install https://projects.unbit.it/downloads/uwsgi-lts.tar.gz

múnla uWSGILink to this heading

feidhmíonn uWSGI ar mhúnla cliant-freastalaí. Déanann do fhreastalaí gréasáin (m.sh., nginx, Apache) cumarsáid le próiseas `` django-uwsgi`` "oibrí" chun freastal ar ábhar dinimiciúil.

An freastalaí UWSgi a chumrú agus a thosú do DjangoLink to this heading

tacaíonn uWSGI le bealaí éagsúla chun an próiseas a chumrú. Féach ar dhoiciméadúchán cumraíochta uWSGI.

Seo ordú samplach chun freastalaí UWSgi a thosú:

Shell
uwsgi --chdir=/path/to/your/project \
    --module=mysite.wsgi:application \
    --env DJANGO_SETTINGS_MODULE=mysite.settings \
    --master --pidfile=/tmp/project-master.pid \
    --socket=127.0.0.1:49152 \      # can also be a file
    --processes=5 \                 # number of worker processes
    --uid=1000 --gid=2000 \         # if root, uwsgi can drop privileges
    --harakiri=20 \                 # respawn processes taking more than 20 seconds
    --max-requests=5000 \           # respawn processes after serving 5000 requests
    --vacuum \                      # clear environment on exit
    --home=/path/to/virtual/env \   # optional path to a virtual environment
    --daemonize=/var/log/uwsgi/yourproject.log      # background the process

Glacann sé leis seo go bhfuil pacáiste tionscadail barrleibhéil agat darb ainm mysite, agus laistigh de modúl:file: mysite/wsgi.py ina bhfuil réad WSGI application. Seo an leagan amach a bheidh agat má rith tú django-admin startproject mysite (ag baint úsáide as d'ainm tionscadail féin in ionad mysite) le leagan le déanaí de Django. Mura bhfuil an comhad seo ann, beidh ort é a chruthú. Féach an doiciméad:doc: /howto/deployment/wsgi/index don ábhar réamhshocraithe ba chóir duit a chur sa chomhad seo agus cad eile is féidir leat a chur leis.

Is iad na roghanna sonracha Django anseo:

  • chdir: An cosán chuig an eolaire a chaithfidh a bheith ar chonair allmhairithe Python - ie, an eolaire ina bhfuil an pacáiste mysite.

  • module: An modúl WSGI le húsáid - is dócha an modúl mysite.wsgi a chruthaíonn: djadmin: startproject.

  • env: Ba chóir go mbeadh ar a laghad: envvar: DJANGO_SETTINGS_MODULE ann.

  • baile: Conair roghnach chuig do thimpeallacht fhíorúil tionscadail.

Sampla an chomhad cumraíochta seo:

Ini
[uwsgi]
chdir=/path/to/your/project
module=mysite.wsgi:application
master=True
pidfile=/tmp/project-master.pid
vacuum=True
max-requests=5000
daemonize=/var/log/uwsgi/yourproject.log

Sampla úsáide comhad cumraíochta seo:

Shell
uwsgi --ini uwsgi.ini

Féach na doiciméid UwsGi maidir le `próiseas UwsGi a bhainistiú `_ le haghaidh faisnéise maidir le tosú, stopadh agus athluchtú oibrithe UWSGI.