我创建了一个烧瓶应用程序,到目前为止一直在使用默认烧瓶服务器来创建/测试它。现在我想将它部署到服务器。我正在使用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错误的网关错误,所以我猜它与我的烧瓶,uwsgi ini / socket有关。
我感谢任何帮助。
答案 0 :(得分:0)
原来我的nginx用户无法访问套接字,因为/和/ home /目录由root用户和root用户拥有。我最终完全访问了所有者和组从/目录到套接字(这可能不是最安全的解决方案安全明智,但我可以在一切正常后进一步完善它。)
答案 1 :(得分:0)
我遇到了同样的问题:
ls -lhtr
/run/myapp/mysock.sock
文件夹中vi mysock.sock
中创建一个空的袜子文件chown user:group /run/myapp/mysock.sock