Kullanılabilir eğiticilerin çoğu uWSGI'yı yukarı akışlı HTTP sunucusuyla (NGINX gibi) nasıl kurulacağını gösterir. Ancak uWSGI tek başına yönlendirici/proxy/yük dengeleyici olarak güzel bir şekilde hareket edebilir - bkz. this Projem için, NGINX'i şu anda kurmak istemedim, böylece web sayfalarını uWSGI aracılığıyla sunma seçeneğini keşfetmeye başladım. Buradaki cevap, Piramit ile nasıl ayarlanacağını gösterir.uWSGI'yi piramitli web sunucusu olarak ayarlama (NGINX yok)
5
A
cevap
10
Ben python3 üzerinde çalışmak için değiştirdim pyramid_mongodb iskele, kullanıyorum. Detaylar için bakınız here. Bir Piramit projemiz olduğunu varsayalım (pcreate -s pyramid_mongodb MyProject
ile oluşturulmuştur). İşte Ayrıca
[uwsgi]
http = 0.0.0.0:8080
#http-to /tmp/uwsgi.sock - use this for standalone mode
#socket = :9050
master = true
processes = 2
harakiri = 60
harakiri-verbose = true
limit-post = 65536
post-buffering = 8192
daemonize = ./uwsgi.log
pidfile = ./orange_uwsgi.pid
listen = 128
max-requests = 1000
reload-on-as = 128
reload-on-rss = 96
no-orphans = true
#logto= <log file>
log-slow = true
virtualenv = <path to virtual environment>
#file = /path/to/pyramid.wsgi
#callable = application
need-app = true
/production.ini gelişiminde ihtiyaç duyulan uWSGI yapılandırmalarıdır biz uWSGI kullandığınız beri sunucu kullanacağım uwsgi --ini-paste development.ini
#[server:main]
#use = egg:waitress#main
#host = 0.0.0.0
#port = 6544
dan server
kısmını dışarı yorum yapabilirsiniz
2
Çok daha kolay! Tüm "development.ini" dosyasında değişiklik yapmaya gerek yok.
from pyramid.paster import get_app,setup_logging
ini_path = '/pathto/myapp/development.ini'
setup_logging(ini_path)
application = get_app(ini_path,'main')
onun içeriği ile en "myapp.conf" diyelim oluşturun: En "gelişme" ve "üretim" ini dosyalarının bulunduğu, aşağıdaki içeriğe sahip "wsgi.app" adlı bir dosya Uygulama klasöründe oluştur :
[uwsgi]
socket = 127.0.0.1:3053
uid = daemon
gid = daemon
venv = /pathto/myenv
project_dir = /pathto/myapp
chdir = %(project_dir)
master = true
plugins = plugins/python/python
check-static = %(project_dir)
static-skip-ext = .py
static-skip-ext = .pyc
static-skip-ext = .inc
static-skip-ext = .tpl
pidfile2 = /var/run/uwsgi/myinfo.pid
disable-logging = true
processes = 8
cheaper = 2
enable-threads = true
offload-threads = N
py-autoreload = 1
wsgi-file = /pathto/myapp/wsgi.py
ve nginx configuation çok basit:// yol/usr /" ile
server {
listen [xxxx:xxxx:xxxx:xxx:xxxx:xxxx]:80; #for IPv6
listen xxx.xxx.xxx.xxx:80; #for IPv4
server_name myapp.domain.com;
location/{
try_files $uri @uwsgi;
}
location @uwsgi {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3053;
}
}
- yeniden başlatma nginx sbin/nginx -s yeniden" uwsgi işlemini başlatmak
- -> değişiklik "" cd /usr/local/uwsgi-2.0.9 -> ./uwsgi -ini /var/www/myapp.conf
Bu durumda NGINX kısmı sadece (isteğe bağlı). Ancak bu noktada, başvuru http://127.0.0.1:3053 adresindeki istekleri dinleyebilmelidir. – SmileMZ