【发布时间】:2014-01-16 21:57:00
【问题描述】:
我已经创建了一个烧瓶应用程序,到目前为止,我一直在使用默认的烧瓶服务器来创建/测试它。现在我想将它部署到服务器。我正在使用 uwsgi 和 nginx,尽管我对两者都很陌生。我知道有很多关于类似事情的指南和问题,但是在我尽可能多地阅读后我找不到解决方案
以下内容来自我的 uwsgi 日志:
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/ben/flask/MLS-Flask
detected binary path: /home/ben/flask/MLS-Flask/mls-flask-ve/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 1024
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 UNIX address /home/ben/flask/MLS-Flask/mls_uwsgi.sock fd 3
Python version: 3.3.3 (default, Dec 30 2013, 16:29:41) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
Set PythonHome to /home/ben/flask/MLS-Flask/mls-flask-ve
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x11755d0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72760 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
added /home/ben/flask/MLS-Flask/ to pythonpath.
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x11755d0 pid: 2926 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 2926, cores: 1)
我假设 uwsgi 至少正在运行?我对此很陌生,所以我不太确定问题出在哪里。
我的 nginx 配置是:
server{
listen 8080;
charset utf-8;
location / {try_files $uri @app; }
location @app {
include uwsgi_params;
uwsgi_pass unix:/home/ben/flask/MLS-Flask/mls_uwsgi.sock;
}
}
我的 uwsgi ini 是:
[uwsgi]
uid = nginx
gid = nginx
base = /home/ben/flask/MLS-Flask
home = %(base)/mls-flask-ve
pythonpath = %(base)
chdir = /home/ben/flask/MLS-Flask
module = runp
#socket file's location
socket = /home/ben/flask/MLS-Flask/mls_uwsgi.sock
#permissions for the socket file
chmod-socket = 666
#variable that holds a flask application inside the module imported
callable = app
#location of log file
logto = /var/log/uwsgi/%n.log
uwsgi ini 正在运行的文件是我的烧瓶应用程序:
from app import app
if __name__ == "__main__":
app.run(debug = False, port = 8080)
我的 uwsgi ini 或 nginx 配置中可能有一些无关的东西,但我不确定这些是否一定是问题所在。谁能看到这可能不起作用的任何原因?我目前在 localhost:8080 上收到 502 bad gateway 错误,所以我猜这与我的烧瓶 uwsgi ini/socket 有关。
感谢您的帮助。
【问题讨论】:
-
我刚才发了这个问题,看看你能不能从中得到什么。 stackoverflow.com/questions/17112805/…