2011-06-09 60 views
1

我以前有過這個問題,但剛剛部署了一個新的網站到一個完全不同的服務器,並有同樣的問題。如果使用Chromium瀏覽網站,它偶爾會掛起。 Chromium向服務器提出了請求,並且只是在那裏等待響應。它保持這樣一分鐘或直到我點擊停止按鈕並再試一次。有時它也掛在響應上 - 鉻中的微調器改變方向,頁面變白,但沒有其他事情發生。mod_wsgi&django定期掛在鉻

要做到這一點,我通常只需快速連續訪問多個頁面。我查看大約10頁後通常會看到這一點。服務器上的'top'顯示沒有任何事情發生(python/wsgi沒有執行),所以它不是超載服務器的問題。命中的訪問日誌中沒有任何內容(即它沒有註冊),也沒有任何內容在錯誤日誌中。

我很難過。請有人指點我的方向,我可能會去調試這個。我不能釋放執行這個目前的方式做:-(

感謝

網站

配置文件如下:

的Apache的conf文件:

<VirtualHost *:80> 
ServerName mysite.org 
ServerAlias www.mysite.* demo.mysite.org 

# Rewrite rules to add 'www.' if it's not present 
RewriteEngine On 
RewriteCond %{HTTP_HOST} !(www|demo)\.mysite.org 
RewriteRule ^(.*)$ http://www.mysite.org$1 [R=301,L] 

WSGIDaemonProcess mycms processes=5 threads=5 display-name=%{GROUP} \ 
    user=nobody group=nobody 

WSGIScriptAlias//var/www/python/mycms/mycms/conf/apache/mycms.wsgi \ 
    process-group=mycms application-group=%{GLOBAL} 

<Directory /var/www/python/mycms/mycms/conf/apache/> 
    WSGIProcessGroup mycms 
    Order deny,allow 
    Allow from all 
</Directory> 

Alias /media/admin/ /var/www/python/mycms/venv/lib/python2.7/site-packages/Django-1.2.5-py2.7.egg/django/contrib/admin/media/ 

<Directory /var/www/python/mycms/venv/lib/python2.7/site-packages/Django-1.2.5-py2.7.egg/django/contrib/admin/media> 
    Order deny,allow 
    Allow from all 
    Options +FollowSymLinks 
</Directory> 

Alias /media/ /var/www/python/mycms/mycms/media/ 

<Directory /var/www/python/mycms/mycms/media> 
    Order deny,allow 
    Allow from all 
</Directory> 
</VirtualHost> 

WSGI:

import os 
import sys 

root = os.path.join(os.path.dirname(__file__), '../../..') 
sys.path.insert(0, root) 

activate_this = os.path.join(root, 'venv/bin/activate_this.py') 
execfile(activate_this, dict(__file__=activate_this)) 

os.environ['PYTHON_EGG_CACHE'] = '/tmp/python-eggs' 
os.environ['DJANGO_SETTINGS_MODULE'] = 'mycms.settings_production' 

import django.core.handlers.wsgi 
application = django.core.handlers.wsgi.WSGIHandler() 

(部分)settings.py:

import os 

# Django settings for mycms project. 

gettext = lambda s: s 

BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 

DATABASES = { 
'default': { 
    'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 
    'NAME': 'mycms',      # Or path to database file if using sqlite3. 
    'USER': 'user',      # Not used with sqlite3. 
    'PASSWORD': 'pass',     # Not used with sqlite3. 
    'HOST': '',      # Set to empty string for localhost. Not used with sqlite3. 
    'PORT': '',      # Set to empty string for default. Not used with sqlite3. 
} 
} 


SITE_ID = 1 

# Absolute path to the directory that holds media. 
# Example: "/home/media/media.lawrence.com/" 
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 

# URL that handles the media served from MEDIA_ROOT. Make sure to use a 
# trailing slash if there is a path component (optional in other cases). 
# Examples: "http://media.lawrence.com", "http://example.com/media/" 
MEDIA_URL = '/media/' 

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a 
# trailing slash. 
# Examples: "http://foo.com/media/", "/media/". 
ADMIN_MEDIA_PREFIX = '/media/admin/' 

# List of callables that know how to import templates from various sources. 
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader', 
'django.template.loaders.app_directories.Loader', 
) 

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'mycms.app.middleware.SiteDetectionMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware', 
'cms.middleware.page.CurrentPageMiddleware', 
'cms.middleware.user.CurrentUserMiddleware', 
'cms.middleware.multilingual.MultilingualURLMiddleware', 
'cms.middleware.toolbar.ToolbarMiddleware', 
'cms.middleware.media.PlaceholderMediaMiddleware', 
) 

ROOT_URLCONF = 'mycms.urls' 

TEMPLATE_DIRS = os.path.join(BASE_DIR, 'templates') 

INSTALLED_APPS = (
'django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.messages', 
'django.contrib.admin', 
'django.contrib.sitemaps', 
'cms', 
'cms.plugins.text', 
'cms.plugins.picture', 
'cms.plugins.link', 
'cms.plugins.file', 
'cms.plugins.teaser', 
'cms.plugins.googlemap', 
'appmedia', 
'mptt', 
'publisher', 
'menus', 
'cmsplugin_contact', 
'mycms.app.html-sitemap', 
'mycms.app.siteprofile', 
'haystack', 
'cms_search', 
'cms_search.search_helpers', 
) 

TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth", 
"django.core.context_processors.i18n", 
"django.core.context_processors.request", 
"django.core.context_processors.media", 
"mycms.app.context_processors.multisite", 
"cms.context_processors.media", 
) 

SiteDetectionMiddleware(禁用此功能雖然不能解決問題)。我正在使用這個功能,因爲我想從一個django安裝服務中說50個站點,並且有一個可以服務所有站點的工作人員池。每個網站只有一個WSGI將預分配資源,但不會允許任何靈活性,站點之間重新分配他們時,有些人比別人更忙:

from django.contrib.sites.models import Site 
from django.conf import settings 
from django.http import HttpResponseServerError 
from mycms.app.siteprofile.models import * 

class SiteDetectionMiddleware: 
    """ 
    Sets the SITE_ID depending on the current HTTP host name. 

    This allows multiple sites with identical settings to be run 
    easily. 
    """ 
    def process_request(self, request): 
     host = request.META.get('HTTP_HOST') 
     if host: 
      try: 
       site = Site.objects.get(domain=host) 
       settings.SITE_ID = site.id 

       profile = Profile.objects.get(site=site) 

       settings.CMS_TEMPLATES = profile.get_template_tuples() + \ 
        (settings.CMS_TEMPLATES[len(settings.CMS_TEMPLATES) - 1],) 
      except Site.DoesNotExist: 
       return HttpResponseServerError() 
      except Profile.DoesNotExist: 
       pass 

回答

0

用途:

http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Tracking_Request_and_Response

來決定是否應該在發生掛起時儘可能地使用mod_wsgi。從那裏調試。

+0

謝謝格雷厄姆。看起來這些請求沒有達到mod_wsgi/apache的程度。 – John 2011-06-11 11:21:55

+0

您正在描述的問題是在某些較舊的Chromimum中繼版本中看到的。嘗試正式發佈。 – 2011-06-12 00:14:41

+0

好的,謝謝。如果這隻影響鉻,我可以忍受它。 – John 2011-06-12 08:16:30