【问题标题】:Mezzanine on HerokuHeroku 上的夹层
【发布时间】:2014-03-01 03:28:04
【问题描述】:

我正在尝试在 Heroku 上安装 Mezzanine (Django) 应用程序。我在项目的应用程序中有一个自定义主题。

我从 herokuapp 网站收到此错误:

Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

我从“heroku 日志”中收到此错误:

2014-03-01T03:16:46.703103+00:00 heroku[web.1]: State changed from crashed to starting
2014-03-01T03:16:52.887091+00:00 heroku[web.1]: Starting process with command `python manage.py collectstatic --noinput; python manage.py run_gunicorn -b 0.0.0.0:48220`
2014-03-01T03:16:54.917679+00:00 app[web.1]: /app/.heroku/python/lib/python2.7/site-packages/mezzanine/utils/conf.py:59: UserWarning: TIME_ZONE setting is not set, using closest match: Etc/UTC
2014-03-01T03:16:54.917679+00:00 app[web.1]:   warn("TIME_ZONE setting is not set, using closest match: %s" % tz)
2014-03-01T03:16:54.945927+00:00 app[web.1]: Unknown command: 'collectstatic'
2014-03-01T03:16:54.945927+00:00 app[web.1]: Type 'manage.py help' for usage.
2014-03-01T03:16:55.283913+00:00 app[web.1]:   warn("TIME_ZONE setting is not set, using closest match: %s" % tz)
2014-03-01T03:16:55.283913+00:00 app[web.1]: /app/.heroku/python/lib/python2.7/site-packages/mezzanine/utils/conf.py:59: UserWarning: TIME_ZONE setting is not set, using closest match: Etc/UTC
2014-03-01T03:16:55.299183+00:00 app[web.1]: Type 'manage.py help' for usage.
2014-03-01T03:16:55.299183+00:00 app[web.1]: Unknown command: 'run_gunicorn'
2014-03-01T03:16:57.198274+00:00 heroku[web.1]: Process exited with status 1
2014-03-01T03:16:57.211687+00:00 heroku[web.1]: State changed from starting to crashed
2014-03-01T03:16:57.213010+00:00 heroku[web.1]: State changed from crashed to starting
2014-03-01T03:17:02.491996+00:00 heroku[web.1]: Starting process with command `python manage.py collectstatic --noinput; python manage.py run_gunicorn -b 0.0.0.0:48145`
2014-03-01T03:17:04.444781+00:00 app[web.1]: /app/.heroku/python/lib/python2.7/site-packages/mezzanine/utils/conf.py:59: UserWarning: TIME_ZONE setting is not set, using closest match: Etc/UTC
2014-03-01T03:17:04.472595+00:00 app[web.1]: Type 'manage.py help' for usage.
2014-03-01T03:17:04.444781+00:00 app[web.1]:   warn("TIME_ZONE setting is not set, using closest match: %s" % tz)
2014-03-01T03:17:04.472595+00:00 app[web.1]: Unknown command: 'collectstatic'
2014-03-01T03:17:04.992615+00:00 app[web.1]: /app/.heroku/python/lib/python2.7/site-packages/mezzanine/utils/conf.py:59: UserWarning: TIME_ZONE setting is not set, using closest match: Etc/UTC
2014-03-01T03:17:04.992615+00:00 app[web.1]:   warn("TIME_ZONE setting is not set, using closest match: %s" % tz)
2014-03-01T03:17:05.080366+00:00 app[web.1]: Unknown command: 'run_gunicorn'
2014-03-01T03:17:05.080366+00:00 app[web.1]: Type 'manage.py help' for usage.
2014-03-01T03:17:06.827562+00:00 heroku[web.1]: Process exited with status 1
2014-03-01T03:17:06.842272+00:00 heroku[web.1]: State changed from starting to crashed
2014-03-01T03:17:08.397089+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=appname request_id=b2f6e7d5-9979-472d-b480-ca36a602f146 fwd="130.126.175.201" dyno= connect
= service= status=503 bytes=

这是我在 settings.py 中安装的应用程序变量(cc 是我的主题/应用程序名称):

INSTALLED_APPS = (
    "cc",
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.redirects",
    "django.contrib.sessions",
    "django.contrib.sites",
    "django.contrib.sitemaps",
    "django.contrib.staticfiles",
    "mezzanine.boot",
    "mezzanine.conf",
    "mezzanine.core",
    "mezzanine.generic",
    "mezzanine.blog",
    "mezzanine.forms",
    "mezzanine.pages",
    "mezzanine.galleries",
    "mezzanine.twitter",
    #"mezzanine.accounts",
    #"mezzanine.mobile",
    "gunicorn",
)

我的 requirements.txt 中有 gunicorn。此外,run_gunicorn 和 collectstatic 在我的 venv 中本地工作。为什么会这样?我遵循了这个:https://gist.github.com/joshfinnie/4046138 for my urls.py(请注意,我的 requirements.txt 是从 pip freeze > requirements.txt 生成的,所以它是最新的)。

这是我的 Procfile:

web: python manage.py collectstatic --noinput; python manage.py run_gunicorn -b 0.0.0.0:$PORT

【问题讨论】:

    标签: python django heroku mezzanine


    【解决方案1】:

    您的 Procfile 是在与 settings.py/manage.py 相同的路径中还是在外部?我遇到了类似的问题,并将我的个人资料在您的项目目录中上移一级。这就是工头在普通 Django 项目上的执行方式。但是,我正在使用 wsgi 运行它。

    这是我的 Procfile

    Procfile: 网页:python manage.py collectstatic --noinput; gunicorn your_project.wsgi -b 0.0.0.0:$PORT

    【讨论】:

    • 根据heroku日志,似乎“collectstatic”不存在。它也不能根据heroku日志导入wsgi模块。我的 Procfile 与 manage.py 和所有内容位于同一目录中,就像 Mezzanine 生成它一样。
    【解决方案2】:

    您似乎没有安装所有必需的应用程序,因此缺少 collectstatic 和 run_gunicorn。确保您的 requirements.txt 包含 Heroku 所需的所有必要包。

    我在当前 Mezzanine 项目上的 requirements.txt 包含:

    Cartridge==0.9.2
    Django==1.6.2
    Mezzanine==3.0.9
    Pillow==2.3.1
    bleach==1.4
    boto==2.27.0
    dj-database-url==0.3.0
    dj-static==0.0.5
    django-s3-storages-utils==0.1.0
    django-storages==1.1.8
    django-toolbelt==0.0.1
    filebrowser-safe==0.3.2
    future==0.9.0
    grappelli-safe==0.3.7
    gunicorn==18.0
    html5lib==0.999
    oauthlib==0.6.1
    pisa==3.0.33
    psycopg2==2.5.2
    pystache==0.5.3
    pytz==2014.2
    requests==2.2.1
    requests-oauthlib==0.4.0
    six==1.6.1
    static==1.0.2
    tzlocal==1.0
    wsgiref==0.1.2
    

    My Mezzanine on Heroku complete how-to is here https://web.archive.org/web/20161018191100/http://www.benhavilland.com/blog/deploying-mezzanine-on-heroku/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-28
      • 2016-02-02
      • 1970-01-01
      • 1970-01-01
      • 2011-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多