为gunicorn起始剧本编辑。
我正在尝试调试在本地运行的应用程序,但我遇到了部署到Heroku的问题。使用heroku local
或gunicorn threepoints.wsgi:application
,我可以看到此堆栈跟踪
10:43:00 AM web.1 | Traceback (most recent call last):
10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
10:43:00 AM web.1 | worker.init_process()
10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
10:43:00 AM web.1 | self.wsgi = self.app.wsgi()
10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
10:43:00 AM web.1 | self.callable = self.load()
10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
10:43:00 AM web.1 | return self.load_wsgiapp()
10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
10:43:00 AM web.1 | return util.import_app(self.app_uri)
10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
10:43:00 AM web.1 | __import__(module)
10:43:00 AM web.1 | File "/Users/cbuddeke/Dropbox/DC-Development/ThreePoints Website/tp/threepoints/wsgi.py", line 19, in <module>
10:43:00 AM web.1 | application = get_wsgi_application()
10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
10:43:00 AM web.1 | django.setup()
10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
10:43:00 AM web.1 | apps.populate(settings.INSTALLED_APPS)
10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
10:43:00 AM web.1 | app_config = AppConfig.create(entry)
10:43:00 AM web.1 | File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 112, in create
10:43:00 AM web.1 | mod = import_module(mod_path)
10:43:00 AM web.1 | File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
10:43:00 AM web.1 | __import__(name)
10:43:00 AM web.1 | ImportError: No module named wagtail
10:43:00 AM web.1 | [2016-10-28 14:43:00 +0000] [24197] [INFO] Worker exiting (pid: 24197)
10:43:00 AM web.1 | [2016-10-28 10:43:00 -0400] [24194] [INFO] Shutting down: Master
10:43:00 AM web.1 | [2016-10-28 10:43:00 -0400] [24194] [INFO] Reason: Worker failed to boot.
我的wsgi.py是
from future import absolute_import, unicode_literals
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE","threepoints.settings.production")
application = get_wsgi_application()
Pip冻结给出了
beautifulsoup4==4.5.1
Django==1.10.1
django-bootstrap3==7.1.0
django-extensions==1.7.4
django-modelcluster==2.0
django-taggit==0.18.3
django-treebeard==4.0.1
djangorestframework==3.4.7
docopt==0.4.0
html5lib==0.999999
mailchimp==2.0.9
Pillow==3.3.1
pytz==2016.6.1
requests==2.11.1
six==1.10.0
Unidecode==0.4.19
wagtail==1.6.2
Werkzeug==0.11.11
whitenoise==3.2.2
Willow==0.3.1
我的设置是
from __future__ import absolute_import, unicode_literals
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
SECRET_KEY = 'xxxxxxxxxxxxxxxxxx'
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)
MAILCHIMP_API_KEY = os.environ["MAILCHIMP_API_KEY"]
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
ALLOWED_HOSTS = [
'threepoints.io',
'localhost',
'three-points.herokuapp.com'
]
# Application definition
INSTALLED_APPS = [
'blog',
'home',
'search',
'wagtail.wagtailforms',
'wagtail.wagtailredirects',
'wagtail.wagtailembeds',
'wagtail.wagtailsites',
'wagtail.wagtailusers',
'wagtail.wagtailsnippets',
'wagtail.wagtaildocs',
'wagtail.wagtailimages',
'wagtail.wagtailsearch',
'wagtail.wagtailadmin',
'wagtail.wagtailcore',
'bootstrap3',
'django_extensions',
'mailchimp',
'modelcluster',
'taggit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
# 'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'wagtail.wagtailcore.middleware.SiteMiddleware',
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
# 'whitenoise.middleware.WhiteNoiseMiddleware',
]
ROOT_URLCONF = 'threepoints.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(PROJECT_DIR, 'templates'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'threepoints.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
STATICFILES_DIRS = [
os.path.join(PROJECT_DIR, 'static'),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
# Wagtail settings
WAGTAIL_SITE_NAME = "threepoints"
# Base URL to use when referring to full URLs within the Wagtail admin backend -
# e.g. in notification emails. Don't include '/admin' or a trailing slash
BASE_URL = 'http://threepoints.io'
我不确定这里出了什么问题。
答案 0 :(得分:0)
您的金枪鱼回溯告诉您问题所在:
ImportError:没有名为w的模块
因此,您需要确保w是可导入的。通常这意味着pip install wagtail
并在virtualenv中使用python运行gunicorn:
gunicorn --pythonpath = / path / to / virtualenv / bin / python threepoints.wsgi