(无法调用或导入错误)没有加载应用。进入完全动态模式

时间:2018-05-23 05:23:47

标签: python django ubuntu-16.04 uwsgi

这几个小时一直困扰着我,不知道发生了什么。当我尝试通过ip访问该网站时。我得到了internal server error

这个词

当我重新启动daemon and uwsgi

时,我收到此错误日志
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 2.7.12 (default, Dec  4 2017, 14:50:18)  [GCC 5.4.0 20160609]
Set PythonHome to /root/wxr/wxr
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xe0db20
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 437520 bytes (427 KB) for 5 cores
*** Operational MODE: preforking ***
Traceback (most recent call last):
  File "./main/wsgi.py", line 10, in <module>
    import os
ImportError: No module named os
unable to load app 0 (mountpoint='') (callable not found or import error)
Traceback (most recent call last):
  File "/root/wxr/wxr/main/wsgi.py", line 10, in <module>
    import os
ImportError: No module named os
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***

我没有虚拟环境设置,因此所有内容都安装在ubuntu 16.04中,直接使用root用户进行设置,而不是拥有其他用户

我将此作为site-available

中的服务器块
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # root /var/www/html;

        # Add index.php to the list if you are using PHP
        # index index.html index.htm index.nginx-debian.html;

        server_name _;

        location = /favicon.ico { access_log off; log_not_found off; }

        location /media  {
                alias /root/wxr/wxr/mediafiles;  # your Django project's media files - amend as required
        }



        location /static/ {
                alias /root/wxr/wxr/static;
        }

        location / {
            include /root/wxr/wxr/uwsgi_params;
            uwsgi_pass unix:/tmp/uwsgi/wxr.sock;
            uwsgi_param Host $host;
            uwsgi_param X-Real-IP $remote_addr;
            uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
            uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;

        }
}

我的/etc/uwsgi/sites/wxr.ini

[uwsgi]
project = wxr
base =/root


#chdir = %(base)/%(project)/%(project)
#home = %(base)/%(project)/%(project)
wsgi-file = /root/wxr/wxr/main/wsgi.py
chdir = /root/wxr/wxr
home = /root/wxr/wxr

module = main.wsgi:application

master = true
processes = 5

socket = /tmp/uwsgi/%(project).sock
chmod-socket = 666
vacuum = true
enable-threads = true
no-site = true

req-logger = file:/tmp/reqlog
logger = file:/tmp/errlog

我的/etc/systemd/system/uwsgi.service

[Unit]
Description=uWSGI Emperor service

[Service]
ExecStartPre=/bin/bash -c 'mkdir -p /tmp/uwsgi; chown root:www-data /tmp/uwsgi'
ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all

[Install]
WantedBy=multi-user.target

0 个答案:

没有答案