Python uwsgi/nginx上的Flask应用程序-unix套接字文件未在引导时创建
我正在尝试在uwsgi/nginx上使用Flask应用程序 跟随 和 ,我可以制作Python uwsgi/nginx上的Flask应用程序-unix套接字文件未在引导时创建,python,sockets,ubuntu,nginx,uwsgi,Python,Sockets,Ubuntu,Nginx,Uwsgi,我正在尝试在uwsgi/nginx上使用Flask应用程序 跟随 和 ,我可以制作wiki.ini文件 [uwsgi] vhost = true socket = /tmp/flask_app.sock venv = /home/ubuntu/webapp/flask/hello/.env chdir = /home/ubuntu/webapp/flask/hello module = flaskapp callable = app chmod-socket = 666 我检查了wiki.in
wiki.ini
文件
[uwsgi]
vhost = true
socket = /tmp/flask_app.sock
venv = /home/ubuntu/webapp/flask/hello/.env
chdir = /home/ubuntu/webapp/flask/hello
module = flaskapp
callable = app
chmod-socket = 666
我检查了wiki.ini
文件,该文件与uwsgi--ini wiki.ini
配合良好
然后,我尝试在启动时启动Flask应用程序
从sudo update rc.d uwsgi enable
,我可以在启动时启动uwsgi服务,并在/etc/uwsgi/apps enabled
目录中复制wiki.ini文件
# simple uWSGI script
# http://uwsgi-docs.readthedocs.org/en/latest/Upstart.html
description "uwsgi tiny instance"
start on runlevel [2345]
stop on runlevel [06]
respawn
exec uwsgi --emperor /etc/uwsgi/apps-enabled
这是nginx的conf文件
server {
listen 80;
server_name wiki.example.com;
access_log /var/log/nginx/uwsgi_access.log;
error_log /var/log/nginx/uwsgi_error.log;
location / { try_files $uri @riki; }
location @riki {
include uwsgi_params;
uwsgi_pass unix:/tmp/flask_app.sock;
}
error_page 404 /404.html;
}
然而,当我重新启动我的ubuntu服务器时,Flask应用程序无法工作。
我检查了错误日志以查找此错误消息
2015/11/07 17:48:17 [crit] 1055#0: *1 connect() to
unix:/tmp/flask_app.sock failed (2: No such file or directory)
while connecting to upstream, client: 68.203.30.28, server: wiki.example.com,
我创建了/tmp/flask_app.sock
文件,并运行chown-R www-data:www-data/tmp/flask_app.sock
使应用程序工作
> touch /tmp/flask_app.sock
> sudo chown www-data:www-data /tmp/flask_app.sock
> sudo service uwsgi restart
> sudo service nginx restart
然而,我有另一个连接错误
2015/11/07 17:50:38 [error] 1055#0: *4 connect() to
unix:/tmp/flask_app.sock failed (111: Connection refused) while
connecting to upstream, client: 68.203.30.28,
server: wiki.example.com, request: "GET / HTTP/1.1",
upstream: "uwsgi://unix:/tmp/flask_app.sock:", host: "wiki.example.com"
可能有什么问题?如何教uwsgi创建unix域套接字?另外,如何使连接工作?我使用ubuntu 14.04
编辑
删除
/tmp/flask\u app.sock
并运行uwsgi--ini/etc/uwsgi/apps enabled/wiki.ini
可以使应用程序正常工作 主要问题似乎来自uwsgi服务;它就是不起作用
我找到了另一种在启动时启动uwsgi的方法:upstart和uwsgi--emperor
from和
这个过程就是在/etc/init
目录中创建一个flask.conf
文件uwsgi--emperon
控制uwsgi目录中的所有ini文件
# simple uWSGI script
# http://uwsgi-docs.readthedocs.org/en/latest/Upstart.html
description "uwsgi tiny instance"
start on runlevel [2345]
stop on runlevel [06]
respawn
exec uwsgi --emperor /etc/uwsgi/apps-enabled
我还必须sudo更新rc.d uwsgi disable
,以便禁用uwsgi服务
我还找到了这个在启动时调用uswgi的站点,但我没有测试它