Периодические сбои Heroku и Django

Я получаю страницу Application Error, когда пытаюсь увидеть свою страницу на героку. Это поведение полностью не зависит от того, что я добавляю какой-либо новый код. Время от времени сайт просто зависает. Обычно он возвращается после нескольких перезагрузок.

Мой procfile выглядит так:

web: python manage.py run_gunicorn -b 0.0.0.0:\$PORT -w 9 -k gevent --max-requests 250 --preload --settings=myblog.production_settings

и вывод heroku logs:

2013-08-27T21:58:35.847326+00:00 heroku[web.1]: Starting process with command `python manage.py run_gunicorn -b 0.0.0.0:\40311 -w 9 -k gevent --max-requests 250 --preload --settings=myblog.production_settings`
2013-08-27T21:58:41.110399+00:00 app[web.1]: 2013-08-27 21:58:41 [2] [INFO] Starting gunicorn 17.5
2013-08-27T21:58:41.150221+00:00 app[web.1]: 2013-08-27 21:58:41 [2] [INFO] Listening at: http://0.0.0.0:40311 (2)
2013-08-27T21:58:41.170382+00:00 app[web.1]: 2013-08-27 21:58:41 [2] [INFO] Using worker: gevent
2013-08-27T21:58:41.456699+00:00 heroku[web.1]: State changed from starting to up
2013-08-27T21:58:41.486410+00:00 app[web.1]: 2013-08-27 21:58:41 [7] [INFO] Booting worker with pid: 7
2013-08-27T21:58:41.847610+00:00 app[web.1]: 2013-08-27 21:58:41 [8] [INFO] Booting worker with pid: 8
2013-08-27T21:58:41.870325+00:00 app[web.1]: [warn] epoll_wait: Invalid argument
2013-08-27T21:58:41.902481+00:00 app[web.1]: Restarting gevent.core.dispatch() after an error [1]: [Errno 22] Invalid argument
2013-08-27T21:58:41.973980+00:00 app[web.1]: 2013-08-27 21:58:41 [9] [INFO] Booting worker with pid: 9
2013-08-27T21:58:41.992755+00:00 app[web.1]: [warn] epoll_wait: Invalid argument
2013-08-27T21:58:42.019851+00:00 app[web.1]: Restarting gevent.core.dispatch() after an error [1]: [Errno 22] Invalid argument
2013-08-27T21:58:42.153919+00:00 app[web.1]: 2013-08-27 21:58:42 [10] [INFO] Booting worker with pid: 10
2013-08-27T21:58:42.214648+00:00 app[web.1]: [warn] epoll_wait: Invalid argument
2013-08-27T21:58:42.241192+00:00 app[web.1]: Restarting gevent.core.dispatch() after an error [1]: [Errno 22] Invalid argument
2013-08-27T21:58:42.318761+00:00 app[web.1]: 2013-08-27 21:58:42 [11] [INFO] Booting worker with pid: 11
2013-08-27T21:58:42.388055+00:00 app[web.1]: Restarting gevent.core.dispatch() after an error [1]: [Errno 22] Invalid argument
2013-08-27T21:58:42.387967+00:00 app[web.1]: [warn] epoll_wait: Invalid argument
2013-08-27T21:58:42.434355+00:00 app[web.1]: 2013-08-27 21:58:42 [12] [INFO] Booting worker with pid: 12
2013-08-27T21:58:42.447753+00:00 app[web.1]: [warn] epoll_wait: Invalid argument
2013-08-27T21:58:42.447753+00:00 app[web.1]: Restarting gevent.core.dispatch() after an error [1]: [Errno 22] Invalid argument
2013-08-27T21:58:42.723659+00:00 app[web.1]: 2013-08-27 21:58:42 [13] [INFO] Booting worker with pid: 13
2013-08-27T21:58:42.727687+00:00 app[web.1]: [warn] epoll_wait: Invalid argument
2013-08-27T21:58:42.727962+00:00 app[web.1]: Restarting gevent.core.dispatch() after an error [1]: [Errno 22] Invalid argument
2013-08-27T21:58:42.849544+00:00 app[web.1]: 2013-08-27 21:58:42 [14] [INFO] Booting worker with pid: 14
2013-08-27T21:58:42.862593+00:00 app[web.1]: [warn] epoll_wait: Invalid argument
2013-08-27T21:58:42.862795+00:00 app[web.1]: Restarting gevent.core.dispatch() after an error [1]: [Errno 22] Invalid argument
2013-08-27T21:58:42.955296+00:00 app[web.1]: 2013-08-27 21:58:42 [15] [INFO] Booting worker with pid: 15
2013-08-27T21:58:42.963033+00:00 app[web.1]: [warn] epoll_wait: Invalid argument
2013-08-27T21:58:42.963581+00:00 app[web.1]: Restarting gevent.core.dispatch() after an error [1]: [Errno 22] Invalid argument
2013-08-27T21:57:34.990876+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=www.mikevella.info fwd="131.111.131.66" dyno=web.1 connect=4ms service=658ms status=404 bytes=3736
2013-08-27T21:57:54.940722+00:00 heroku[router]: at=info method=GET path=/static/zinnia/css/print.css host=www.mikevella.info fwd="131.111.131.66" dyno=web.1 connect=2ms service=21ms status=304 bytes=0
2013-08-27T21:57:33.951480+00:00 heroku[router]: at=info method=GET path=/static/zinnia/css/screen.css host=www.mikevella.info fwd="131.111.131.66" dyno=web.1 connect=6ms service=27ms status=304 bytes=0
2013-08-27T21:57:48.813571+00:00 heroku[router]: at=info method=GET path=/static/zinnia/css/print.css host=www.mikevella.info fwd="131.111.131.66" dyno=web.1 connect=25ms service=26ms status=304 bytes=0
2013-08-27T21:58:31.985574+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path=/ host=www.mikevella.info fwd="131.111.131.66" dyno=web.1 connect=1ms service=2044ms status=503 bytes=0

Мой файл настроек выглядит следующим образом (я удалил конфиденциальную информацию):

# Django settings for myblog project.

#Note: as of 25/08/13 all this is configured for use on Heroku, need
#to make it more generic

import os

DEBUG = False TEMPLATE_DEBUG = False


SECRET_KEY = 'REMOVED'

ADMINS = (
    # ('Your Name', '[email protected]'), )

MANAGERS = ADMINS

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
#ALLOWED_HOSTS = []

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone. TIME_ZONE = 'GMT'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-uk'

#a bit of an ugly statement: SITE_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery. USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale. USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/" MEDIA_ROOT = SITE_ROOT + '/media'

ZINNIA_UPLOAD_TO='uploads'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/" MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/" STATICFILES_DIR = ('zinna/static',)

# Static root configuration STATIC_ROOT = SITE_ROOT

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
#STATIC_URL = '/home/mike/dev/myblog/static/' STATIC_URL = '/static/'

# Additional locations of static files STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    '/home/mike/dev/myblog/zinnia/static', )

# List of finder classes that know how to find static files in
# various locations. STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder', )

# 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',
    #    'django.template.loaders.eggs.Loader', )

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware', )

ROOT_URLCONF = 'myblog.urls'

# Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'myblog.wsgi.application'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    'templates', )

TEMPLATE_CONTEXT_PROCESSORS = (   'django.contrib.auth.context_processors.auth',   'django.core.context_processors.i18n',   'django.core.context_processors.request',   'django.core.context_processors.media',   'zinnia.context_processors.version', # Optional
#  'zinnia.context_processors.media', #trying to solve heroku pain with this   )

Похоже, это не связано с аналогичной ошибкой, о которой я писал ранее. мог бы опубликовать это там, если люди думают, что это лучше.


person Mike Vella    schedule 27.08.2013    source источник


Ответы (1)


Я бы настоятельно не рекомендовал делать --max-requests 250 с gevent — это полностью противоречит цели его использования :)

person Kenneth Reitz    schedule 24.10.2014