尝试使用uWSGI部署Python Pyramid应用程序

3

我正在尝试使用uWSGI部署一个pyramid应用程序。

当使用包含的pyramid开发服务器时,该应用程序可以正常工作。

此外,我以前已经设置过这个,我发誓它曾经起作用过。

但是,现在输入魔法短语却导致“此网页不可用”。

我正在尝试保持所有配置参数与当前配置尽可能相似,以便不必担心防火墙问题。

development.ini中uWSGI部分如下(来自:Setup uWSGI as webserver with pyramid (no NGINX)):

[uwsgi]
socket = localhost:8080
virtualenv = /var/www/finance/finance-env
die-on-term = 1
master = 1
#logto = /var/log/wsgi/uwsgi.log


enable-threads = true
offload-threads = N
py-autoreload = 1
wsgi-file = /var/www/finance/wsgi.py

wsgy.py看起来像这样:

from pyramid.paster import get_app, setup_logging
ini_path = '/var/www/finance/corefinance/development.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main')

这是当前的输出。一切似乎在8080端口上都监听得很好。

user1@finance1:~$ sudo /var/www/finance/finance-env/bin/uwsgi --ini-paste-logg /var/www/finance/corefinance/development.ini
[uWSGI] getting INI configuration from /var/www/finance/corefinance/development.ini
*** Starting uWSGI 2.0.11.2 (64bit) on [Fri Jan 15 21:13:31 2016] ***
compiled with version: 4.7.2 on 16 November 2015 20:13:35
os: Linux-4.1.5-x86_64-linode61 #7 SMP Mon Aug 24 13:46:31 EDT 2015
nodename: finance1
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/user1
detected binary path: /var/www/finance/finance-env/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your processes number limit is 3934
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address localhost:8080 fd 3
Python version: 3.2.3 (default, Feb 20 2013, 14:49:46)  [GCC 4.7.2]
Set PythonHome to /var/www/finance/finance-env
Python main interpreter initialized at 0xfd0a10
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0xfd0a10 pid: 6275 (default app)
mountpoint  already configured. skip.
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 6275)
spawned uWSGI worker 1 (pid: 6282, cores: 1)
Python auto-reloader enabled

1
在 ini 文件中,将 socket = localhost:8080 替换为 http = 0.0.0.0:8080 - reptilicus
1
http 使用 uwsgi 的 http 路由,如果没有它,你需要在代理后面,比如 nginx。 - reptilicus
@reptilicus,搞定了。想要回答以获取积分吗? - Jeremy T
1个回答

2

除非您在nginx等代理后面,否则您需要使用uwsgi中的内部http路由支持。修改

socket = localhost:8080

to

http = 0.0.0.0:8080

这里是uWSGI HTTP支持文档



网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接