0

这个问题已经被问过很多次了,我已经尝试了每一个关于部署堆栈的解决方案,唉。这是出于绝望,我再次在这里重复这个问题。

我的部署方案:

/srv    .
├── env
│   ├── bin
│   ├── include
│   │   ├── python2.7 -> /usr/include/python2.7
│   │   └── site
│   ├── lib
│   │   └── python2.7
│   ├── local
│   │   ├── bin -> /srv/env/bin
│   │   ├── include -> /srv/env/include
│   │   └── lib -> /srv/env/lib
│   └── src
│       ├── authorizesauce
│       ├── couchdb
│       ├── django-haystack
│       └── django-js-utils
├── html
├── http
├── log
├── solr
├── ssl
└── www
    └── SC
        └── webapp
            └── core
                └── individual

/srv/env虚拟环境 在哪里/srv/log用于日志文件存储,我的Django 应用程序中的文件存在uwsgi reload于我所有的 ssl 相关文件中,用于部署,并且没有被使用。 /srv/reload/srv/www/SC/webapp/srv/ssl/srv/solrapache solr/srv/html/srv/http

/srv/www/SC/webapp是文件夹有settings.py manage.py

/srv/www/SC/webapp/core/是核心应用程序文件夹,带有individualasAbstractUser

nginx版本是1.1.19
uwsgi版本是1.9.18.2
operating systemubuntu 1.04 LTS 64 bit
托管在亚马逊AWS上

uwsgi配置

[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /srv/www/SC/webapp

# the virtualenv (full path)

virtualenv = /srv/env

env = DJANGO_SETTINGS_MODULE = settings

# Django's wsgi file
module = uwsgi

master = true
#multithreading
enable-threads = true
# maximum number of worker processes
processes = 4

# the socket (use the full path to be safe
socket          = /tmp/dev.sc.com.sock
# ... with appropriate permissions - may be needed
chmod-socket    = 664
# clear environment on exit
vacuum = true

#pythonpath
pythonpath = /srv/www/SC/webapp
pythonpath = /srv/www/SC/webapp/settings.py
pythonpath = /srv/www/SC/webapp/core
pythonpath = /srv/www/SC/webapp/core/individual

#reloadfile
touch-reload = /srv/reload

uwsgi 文件

import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

nginx 配置

    upstream django {
    server unix:/tmp/dev.sc.com.sock;
    }
    server {
    listen     80;
    rewrite ^ https://sc.com$request_uri? permanent;
   }    
    server {
        listen 443;
        server_name .sc.com;

        ssl on;
        ssl_certificate /srv/ssl/sc.bundle.crt;
        ssl_certificate_key /srv/ssl/sc.key;
        # max upload size
        client_max_body_size 75M;   # adjust to taste

        # Django media
        location /media  {
            alias /srv/www/SC/webapp/media;
        }

        location /static {
            alias /srv/www/SC/webapp/site_static;
        }


        location / {
            uwsgi_pass unix:/tmp/dev.sc.com.sock;
            uwsgi_read_timeout 6000;
            uwsgi_send_timeout 6000;
            include /etc/nginx/uwsgi_params;
            index  index.html index.htm;
            uwsgi_param X-Forwarded-Proto https;
            uwsgi_param X-Real-IP $remote_addr;
            uwsgi_param Host $http_host;
            }
    }

问题

python manage.py runserver应用程序一起运行时运行良好。部署启动后
立即提高uwsgi

ImproperlyConfigured("AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL)
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'individual.Individual' that has not been installed

开始出现,而且非常随机,有时它只是起作用(比如 50% 的时间),我不确定可能是什么问题。

问题 2

显示uwsgi这些日志

    unable to load app 0 (mountpoint='') (callable not found or import error)
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x199c500 pid: 28242 (default app)

完整的日志

[uWSGI] getting INI configuration from /srv/www/SC/webapp/wsgi.working.ini
*** Starting uWSGI 1.9.18.2 (64bit) on [Mon Oct 28 15:57:49 2013] ***
compiled with version: 4.6.3 on 28 October 2013 12:58:05
os: Linux-3.2.0-54-virtual #82-Ubuntu SMP Tue Sep 10 20:31:18 UTC 2013
nodename: ip-10-168-14-146
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /srv/www/SC/webapp
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 59476
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 /tmp/dev.sc.com.sock fd 3
Python version: 2.7.3 (default, Sep 26 2013, 20:13:52)  [GCC 4.6.3]
Set PythonHome to /srv/env
Python main interpreter initialized at 0x199c500
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 364000 bytes (355 KB) for 4 cores
*** Operational MODE: preforking ***
added /srv/www/SC/webapp/ to pythonpath.
added /srv/www/SC/webapp/settings.py to pythonpath.
added /srv/www/SC/webapp/core/ to pythonpath.
added /srv/www/SC/webapp/core/individual/ to pythonpath.
unable to load app 0 (mountpoint='') (callable not found or import error)
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x199c500 pid: 28242 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 28242)
spawned uWSGI worker 1 (pid: 28243, cores: 1)
spawned uWSGI worker 2 (pid: 28244, cores: 1)
spawned uWSGI worker 3 (pid: 28245, cores: 1)
spawned uWSGI worker 4 (pid: 28246, cores: 1)

任何指针都会有很大帮助。

我已经告诉了我能收集到的一切。

4

1 回答 1

0

开始将 uwsgi.py 重命名为其他名称(并相应地更改模块选项),因为您很快就会得到与嵌入式“uwsgi”模块的名称冲突。

uwsgi_param 不采用 http 标头,但采用 WSGI/CGI 变量(主机和 Real-Ip 绝对不需要)

于 2013-10-28T17:41:49.293 回答