【问题标题】:Uwsgi wont load app when run as serviceUwsgi 作为服务运行时不会加载应用程序
【发布时间】:2017-01-10 11:10:11
【问题描述】:

我在 Centos 6 中设置了一个基本的烧瓶应用程序,所有内容都包含在一个文件(app.py)中。我可以使用命令uwsgi --ini myuwsgi.ini 从文件夹目录中使用uwsgi 运行该文件,并且一切正常。 ini文件的内容是:

[uwsgi]
http-socket    = :9090
plugin    = python
wsgi-file = /project/app.py
process   = 3
callable = app

但是我想设置它,以便每次服务器关闭或它自己出现的任何情况。当我尝试运行命令service uwsgi start 时,日志显示未找到任何应​​用程序。服务使用的ini文件是/etc/uwsgi.ini,我用我的ini文件替换了它。

如果有帮助的话,日志的转储如下:

*** Starting uWSGI 2.0.13.1 (64bit) on [Fri Sep  2 07:49:37 2016] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-17) on 02 August 2016 21:07:31
os: Linux-2.6.32-042stab113.21 #1 SMP Wed Mar 23 11:05:25 MSK 2016
nodename: uwsgiHost
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /
detected binary path: /usr/sbin/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 14605
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 :9090 fd 3
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72768 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 1315, cores: 1)
-- unavailable modifier requested: 0 --

如果有人能告诉我为什么当我在 ini 中指定位置和可调用时它找不到应用程序?

【问题讨论】:

    标签: python service flask centos uwsgi


    【解决方案1】:

    尝试以下配置,让我知道它是否适合您:

    [uwsgi]
    callable = app
    chdir = /path/to/your/project/
    http-socket = :9090
    plugins = python
    processes = 4
    virtualenv = /path/to/your/project/venv
    wsgi-file = /path/to/your/project/app.py
    

    您可能还需要添加 uidgid 参数。

    确保你已经安装了包uwsgi-plugin-python

    apt-get install uwsgi-plugin-python
    

    【讨论】:

    • 我添加了那个参数并没有好处,我还添加了:uid = 10000 和 gid = 10000 但没有好处。你如何设置uid值?遇到同样的错误。
    • 解决了这个问题,谢谢老兄!
    猜你喜欢
    • 2014-05-29
    • 2019-12-25
    • 1970-01-01
    • 1970-01-01
    • 2010-11-27
    • 2019-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多