我是NGINX,uWSGI和Pyramid的新手,我正试图通过uWSGI使用nginx作为反向代理服务金字塔应用。我现在真的陷入困境,希望有人能就如何解决这个问题提出一些建议。如果你能解释一下可能会发生什么,那也会有所帮助,因为我的理解非常有限!
目前,我收到的是“内部服务器错误”。当我访问反向代理URL时,来自uWSGI。在uWSGI错误日志中,我收到错误:
--- no python application found, check your startup logs for errors ---
当我通过uWSGI单独服务时,应用程序正常工作,与pserve一起启动。我可以从虚拟信封中启动它,如下所示:
bin/pserve my-app/uwsgi.ini
但是当我启动nginx并访问代理地址时,我收到内部服务器错误。
我在uwsgi.ini中的设置如下:
[app:main]
use = egg:myapp
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en
pyramid_debugtoolbar
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
[loggers]
keys = root, musiccircle
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = ERROR
handlers = console
[logger_musiccircle]
level = ERROR
handlers =
qualname = musiccircle
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
[uwsgi]
socket = unix://home/usr/env/myapp/myapp.sock
master = true
processes = 48
cpu-affinity = 12
harakiri = 60
post-buffering = 8192
buffer-size = 65535
daemonize = ./uwsgi.log
pidfile = ./pid_5000.pid
listen = 32767
reload-on-as = 512
reload-on-rss = 192
limit-as = 1024
no-orphans = true
reload-mercy = 8
log-slow = true
virtualenv = /home/usr/env
在nginx的相应myapp.conf文件中,我有以下内容:
upstream myapp {
server 127.0.0.1:6543;
}
server {
listen 8080;
server_name myapp.local www.myapp.local;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/usr/env/myapp;
}
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
charset utf-8;
location / {
include uwsgi_params;
uwsgi_pass unix://home/usr/env/myapp/myapp.sock;
}
}
如果您还需要查看其他内容,请告知我们。正如您所看到的,Nginx配置为在端口8080(它可以)服务,而金字塔应用程序由uWSGI服务到端口6543(它确实如此)。
提前致谢。
答案 0 :(得分:1)
Pyramid项目似乎是安装(CRUD
),然后使用BaseDaoImpl
setup.py
配置文件运行。然后,Pserve会在运行时将这些配置文件详细信息作为.ini
传递给您的Pyramid应用程序。
这与Flask没有未安装并且通常具有 no 配置文件不同。这样的Flask应用程序可以根据需要由uWSGI运行,所有运行时配置都由uWSGI或环境变量处理。
由于Pyramid在运行时通常需要配置文件,并且在使用配置文件(即pserve
)时依赖pserve提供它们,我认为您必须运行**settings
(或者如果与Pypy一起运行,production.ini
)(感谢@Sorrel)