【发布时间】:2013-11-07 14:02:22
【问题描述】:
这个问题已经被问过很多次了,我已经尝试了每一个关于部署堆栈的解决方案,唉。 这是出于绝望,我再次在这里重复这个问题。
我的部署场景:
/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 用于日志文件存储
,我的uwsgi reload文件在/srv/reload我的Django应用程序位于/srv/www/SC/webapp我所有的ssl相关文件都在/srv/ssl,/srv/solr用于apache solr部署,/srv/html和/srv/http不是用过的。
/srv/www/SC/webapp 是具有settings.py manage.py 的文件夹
/srv/www/SC/webapp/core/ 是核心应用程序文件夹,individual 为 AbstractUser
nginx 版本是1.1.19uwsgi 版本是1.9.18.2operating system 是ubuntu 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)
任何指针都会有很大帮助。
我已经告诉了我能收集到的一切。
【问题讨论】:
标签: python django amazon-web-services nginx uwsgi