问题描述
我试图用uwsgi + supervisor + nginx来运行Flask应用程序。
uwsgi安装在conda env中,我可以运行我的应用程序问题没有主管,即如果我运行(与我的conda env激活):
uwsgi --ini / home / me / Development /flask/myflaskapp/myflaskapp.ini
使用以下配置:
/home/me/Development/flask/myflaskapp/myflaskapp.ini
[uwsgi]
chmod-socket = 666
socket = /home/me/Development/flask/myflaskapp/run/myflaskapp.sock
module = wsgi
callable = app
vim / etc / nginx / sites-available / myflaskapp
server {
with
listen 8000;
server_name localhost;
client_max_body_size 50M;
位置/ {
包含uwsgi_params;
uwsgi_pass unix:/home/me/Development/flask/myflaskapp/run/myflaskapp.sock;
现在我创建一个管理员配置文件:
/etc/supervisor/conf.d/uwsgi-myflaskapp.conf
[program:uwsgi-myflaskapp]
command = / home / me / Development / miniconda / envs / myflaskapp / bin / uwsgi /home/me/Development/flask/myflaskapp/myflaskapp.ini
autostart = true
autorestart = true
stdout_logfile = / home / me / Development / flask / myflaskapp / log / uwsgi-myflaskapp.log
redirect_stderr = true
exitcodes = 0
我使用 $启动supervisor(系统范围安装) b $ b
sudo service supervisor start
用
sudo supervisorctl重新加载$ b $ b
但我在日志文件中得到以下错误:
ImportError:No module named wsgi
有什么建议?
完整的日志:
$ b $[uWSGI]从/home/me/Development/flask/myflaskapp/myflaskapp.ini获取INI配置
***启动uWSGI 2.0.12(64bit)于[星期一1月11日19:12:14 2016] ***
编译版本:4.8.4 2016年1月11日10:54:59
os:Linux-3.13 .0-74-generic#118-Ubuntu SMP Thu Dec 17 22:52:10 UTC 2015
nodename:roquefort
机器:x86_64
时钟源:unix
pcre jit禁用
检测到CPU核心数目:4
当前工作目录:/
检测二进制路径:/ home / me / Development / miniconda / envs / myflaskapp / bin / uwsgi
uWSGI正在运行作为根,你可以使用--uid / - gid / - chroot选项
***警告:你正在运行uWSGI作为root! (使用--uid标志)***
***警告:您正在运行uWSGI而没有其主进程管理器***
您的进程数限制为63047
您的内存页大小是4096字节
检测到的最大文件描述符数量:1024
锁定引擎:pthread强大的互斥体
thunder lock:禁用(可以使用--thunder-lock启用它)
uwsgi socket 0绑定到UNIX地址/home/me/Development/flask/myflaskapp/run/myflaskapp.sock fd 3
Python版本:2.7.11 | Continuum Analytics,Inc. | (默认,2015年12月6日18:08:32)[GCC 4.4.7 20120313(Red Hat 4.4.7-1)]
***禁用Python线程支持。您可以使用--enable-threads启用它***
Python主要解释器初始化为0x18001e0
您的服务器套接字监听待办事项被限制为100个连接
您对工作者优美操作的仁慈是60秒
映射72760字节(71 KB)for 1 cores
***操作模式:单进程***
ImportError:没有名为wsgi的模块
无法加载应用程序0 mountpoint ='')(可找不到或导入错误)
***没有应用程序加载。进入完全动态模式***
*** uWSGI运行在多种解释器模式下***
衍生的uWSGI工作者1(并且唯一的)(pid:24671,核心:1)
解决方案wsgi.py文件的路径是在code> /home/me/Development/flask/myflaskapp/myflaskapp.ini
chdir = / home / me / Development / flask / myflaskapp
现在可以找到wsgi。 / p>
I'm trying to run a Flask app with uwsgi + supervisor + nginx.
uwsgi is installed in a conda env, and I can run my app with no issue without supervisor, i.e. if I run (with my conda env activated):
uwsgi --ini /home/me/Development/flask/myflaskapp/myflaskapp.ini
with the following config:
/home/me/Development/flask/myflaskapp/myflaskapp.ini
[uwsgi] chmod-socket = 666 socket = /home/me/Development/flask/myflaskapp/run/myflaskapp.sock module = wsgi callable = app
vim /etc/nginx/sites-available/myflaskapp
server { listen 8000; server_name localhost; client_max_body_size 50M; location / { include uwsgi_params; uwsgi_pass unix:/home/me/Development/flask/myflaskapp/run/myflaskapp.sock; } }
Now I create a supervisor config file:
/etc/supervisor/conf.d/uwsgi-myflaskapp.conf
[program:uwsgi-myflaskapp] command=/home/me/Development/miniconda/envs/myflaskapp/bin/uwsgi /home/me/Development/flask/myflaskapp/myflaskapp.ini autostart=true autorestart=true stdout_logfile=/home/me/Development/flask/myflaskapp/log/uwsgi-myflaskapp.log redirect_stderr=true exitcodes=0
I start supervisor (installed system-wide) with
sudo service supervisor start
and load the conf file with
sudo supervisorctl reload
but I get the following error in the log file:
ImportError: No module named wsgi
Any suggestion?
Here's the complete log:
[uWSGI] getting INI configuration from /home/me/Development/flask/myflaskapp/myflaskapp.ini *** Starting uWSGI 2.0.12 (64bit) on [Mon Jan 11 19:12:14 2016] *** compiled with version: 4.8.4 on 11 January 2016 10:54:59 os: Linux-3.13.0-74-generic #118-Ubuntu SMP Thu Dec 17 22:52:10 UTC 2015 nodename: roquefort machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 4 current working directory: / detected binary path: /home/me/Development/miniconda/envs/myflaskapp/bin/uwsgi uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** *** WARNING: you are running uWSGI without its master process manager *** your processes number limit is 63047 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/me/Development/flask/myflaskapp/run/myflaskapp.sock fd 3 Python version: 2.7.11 |Continuum Analytics, Inc.| (default, Dec 6 2015, 18:08:32) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] *** Python threads support is disabled. You can enable it with --enable-threads *** Python main interpreter initialized at 0x18001e0 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 *** ImportError: No module named wsgi unable to load app 0 (mountpoint='') (callable not found or import error) *** no app loaded. going in full dynamic mode *** *** uWSGI is running in multiple interpreter mode *** spawned uWSGI worker 1 (and the only) (pid: 24671, cores: 1)
解决方案I added the the path of the wsgi.py file in
/home/me/Development/flask/myflaskapp/myflaskapp.ini
withchdir = /home/me/Development/flask/myflaskapp
so that it can now find wsgi.
这篇关于在conda env中使用supervisor和uwsgi发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!