HEROKU DJANGO PYTHON APP 因应用程序错误而崩溃

问题描述

我第一次将 heroku 应用程序部署到 DJANGO 时遇到了困难。我已经加载了应用程序并且它可以工作,但没有加载所有的 css。它也没有正确调整图像大小,似乎缺少模板和引导样式表。

它还删除了重新启动 dyno 时加载到应用程序中的图像。我已升级到业余爱好计划。

我已经做了 heroku 指出的更改,包括以下内容: 第一次提交: #BASE_DIR = Path(file).resolve().parent.parent 第二次提交: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))

我正在使用白噪声处理 img。

追溯

2021-05-06T23:38:58.920990+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py",line 589,in spawn_worker
2021-05-06T23:38:58.921004+00:00 app[web.1]: worker.init_process()
2021-05-06T23:38:58.921005+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py",line 134,in init_process
2021-05-06T23:38:58.921005+00:00 app[web.1]: self.load_wsgi()
2021-05-06T23:38:58.921005+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py",line 146,in load_wsgi
2021-05-06T23:38:58.921006+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-05-06T23:38:58.921014+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py",line 67,in wsgi
2021-05-06T23:38:58.921014+00:00 app[web.1]: self.callable = self.load()
2021-05-06T23:38:58.921014+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py",line 58,in load
2021-05-06T23:38:58.921014+00:00 app[web.1]: return self.load_wsgiapp()
2021-05-06T23:38:58.921015+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py",line 48,in load_wsgiapp
2021-05-06T23:38:58.921015+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-05-06T23:38:58.921015+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py",line 359,in import_app
2021-05-06T23:38:58.921016+00:00 app[web.1]: mod = importlib.import_module(module)
2021-05-06T23:38:58.921016+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py",line 127,in import_module
2021-05-06T23:38:58.921017+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:],package,level)
2021-05-06T23:38:58.921017+00:00 app[web.1]: File "<frozen importlib._bootstrap>",line 1030,in _gcd_import
2021-05-06T23:38:58.921018+00:00 app[web.1]: File "<frozen importlib._bootstrap>",line 1007,in _find_and_load
2021-05-06T23:38:58.921018+00:00 app[web.1]: File "<frozen importlib._bootstrap>",line 986,in _find_and_load_unlocked
2021-05-06T23:38:58.921018+00:00 app[web.1]: File "<frozen importlib._bootstrap>",line 680,in _load_unlocked
2021-05-06T23:38:58.921019+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>",line 855,in exec_module
2021-05-06T23:38:58.921019+00:00 app[web.1]: File "<frozen importlib._bootstrap>",line 228,in _call_with_frames_removed
2021-05-06T23:38:58.921019+00:00 app[web.1]: File "/app/mart/wsgi.py",line 16,in <module>
2021-05-06T23:38:58.921020+00:00 app[web.1]: application = get_wsgi_application()
2021-05-06T23:38:58.921020+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/core/wsgi.py",line 12,in get_wsgi_application
2021-05-06T23:38:58.921021+00:00 app[web.1]: django.setup(set_prefix=False)
2021-05-06T23:38:58.921021+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/__init__.py",line 19,in setup
2021-05-06T23:38:58.921021+00:00 app[web.1]: configure_logging(settings.LOGGING_CONfig,settings.LOGGING)
2021-05-06T23:38:58.921022+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py",line 82,in __getattr__
2021-05-06T23:38:58.921022+00:00 app[web.1]: self._setup(name)
2021-05-06T23:38:58.921022+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py",line 69,in _setup
2021-05-06T23:38:58.921023+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2021-05-06T23:38:58.921023+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py",line 170,in __init__
2021-05-06T23:38:58.921023+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2021-05-06T23:38:58.921024+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py",in import_module
2021-05-06T23:38:58.921024+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:],level)
2021-05-06T23:38:58.921024+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _gcd_import
2021-05-06T23:38:58.921025+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load
2021-05-06T23:38:58.921025+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load_unlocked
2021-05-06T23:38:58.921025+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _load_unlocked
2021-05-06T23:38:58.921026+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>",in exec_module
2021-05-06T23:38:58.921026+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _call_with_frames_removed
2021-05-06T23:38:58.921026+00:00 app[web.1]: File "/app/mart/settings.py",line 88,in <module>
2021-05-06T23:38:58.921027+00:00 app[web.1]: 'NAME': BASE_DIR / 'db.sqlite3',2021-05-06T23:38:58.921027+00:00 app[web.1]: TypeError: unsupported operand type(s) for /: 'str' and 'str'
2021-05-06T23:38:58.921187+00:00 app[web.1]: [2021-05-06 23:38:58 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-05-06T23:38:58.926921+00:00 app[web.1]: [2021-05-06 23:38:58 +0000] [7] [ERROR] Exception in worker process
2021-05-06T23:38:58.926923+00:00 app[web.1]: Traceback (most recent call last):
2021-05-06T23:38:58.926923+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py",in spawn_worker
2021-05-06T23:38:58.926924+00:00 app[web.1]: worker.init_process()
2021-05-06T23:38:58.926925+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py",in init_process
2021-05-06T23:38:58.926925+00:00 app[web.1]: self.load_wsgi()
2021-05-06T23:38:58.926925+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py",in load_wsgi
2021-05-06T23:38:58.926926+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-05-06T23:38:58.926926+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py",in wsgi
2021-05-06T23:38:58.926927+00:00 app[web.1]: self.callable = self.load()
2021-05-06T23:38:58.926927+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py",in load
2021-05-06T23:38:58.926927+00:00 app[web.1]: return self.load_wsgiapp()
2021-05-06T23:38:58.926928+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py",in load_wsgiapp
2021-05-06T23:38:58.926928+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-05-06T23:38:58.926928+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py",in import_app
2021-05-06T23:38:58.926929+00:00 app[web.1]: mod = importlib.import_module(module)
2021-05-06T23:38:58.926929+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py",in import_module
2021-05-06T23:38:58.926930+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:],level)
2021-05-06T23:38:58.926930+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _gcd_import
2021-05-06T23:38:58.926931+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load
2021-05-06T23:38:58.926931+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load_unlocked
2021-05-06T23:38:58.926932+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _load_unlocked
2021-05-06T23:38:58.926932+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>",in exec_module
2021-05-06T23:38:58.926932+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _call_with_frames_removed
2021-05-06T23:38:58.926933+00:00 app[web.1]: File "/app/mart/wsgi.py",in <module>
2021-05-06T23:38:58.926933+00:00 app[web.1]: application = get_wsgi_application()
2021-05-06T23:38:58.926934+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/core/wsgi.py",in get_wsgi_application
2021-05-06T23:38:58.926934+00:00 app[web.1]: django.setup(set_prefix=False)
2021-05-06T23:38:58.926934+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/__init__.py",in setup
2021-05-06T23:38:58.926935+00:00 app[web.1]: configure_logging(settings.LOGGING_CONfig,settings.LOGGING)
2021-05-06T23:38:58.926935+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py",in __getattr__
2021-05-06T23:38:58.926936+00:00 app[web.1]: self._setup(name)
2021-05-06T23:38:58.926936+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py",in _setup
2021-05-06T23:38:58.926936+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2021-05-06T23:38:58.926937+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py",in __init__
2021-05-06T23:38:58.926937+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2021-05-06T23:38:58.926937+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py",in import_module
2021-05-06T23:38:58.926938+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:],level)
2021-05-06T23:38:58.926947+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _gcd_import
2021-05-06T23:38:58.926948+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load
2021-05-06T23:38:58.926948+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load_unlocked
2021-05-06T23:38:58.926948+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _load_unlocked
2021-05-06T23:38:58.926949+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>",in exec_module
2021-05-06T23:38:58.926949+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _call_with_frames_removed
2021-05-06T23:38:58.926949+00:00 app[web.1]: File "/app/mart/settings.py",in <module>
2021-05-06T23:38:58.926950+00:00 app[web.1]: 'NAME': BASE_DIR / 'db.sqlite3',2021-05-06T23:38:58.926950+00:00 app[web.1]: TypeError: unsupported operand type(s) for /: 'str' and 'str'
2021-05-06T23:38:58.927280+00:00 app[web.1]: [2021-05-06 23:38:58 +0000] [7] [INFO] Worker exiting (pid: 7)
2021-05-06T23:38:58.999882+00:00 app[web.1]: [2021-05-06 23:38:58 +0000] [4] [WARNING] Worker with pid 7 was terminated due to signal 15
2021-05-06T23:38:59.097343+00:00 app[web.1]: [2021-05-06 23:38:59 +0000] [4] [INFO] Shutting down: Master
2021-05-06T23:38:59.097481+00:00 app[web.1]: [2021-05-06 23:38:59 +0000] [4] [INFO] Reason: Worker Failed to boot.
2021-05-06T23:38:59.157307+00:00 heroku[web.1]: Process exited with status 3
2021-05-06T23:38:59.227286+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-06T23:39:18.072250+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pharmamart.herokuapp.com request_id=b5d5de53-f42e-4739-acc4-9280a4897961 fwd="1.129.105.115" dyno= connect= service= status=503 bytes= protocol=https

SETTINGS.PY


"""
Django settings for mart project.

Generated by 'django-admin startproject' using Django 3.1.4.

For more information on this file,see
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values,see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
from decouple import config,Csv
import os 
import django_heroku
import dj_database_url

# Build paths inside the project like this: BASE_DIR / 'subdir'.
#BASE_DIR = Path(__file__).resolve().parent.parent
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# Security WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY')

# Security WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG',default=False,cast=bool)

ALLOWED_HOSTS = config('ALLOWED_HOSTS',cast=Csv())


# Application deFinition

INSTALLED_APPS = [
    'django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','rest_framework','store','widget_tweaks',]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware','whitenoise.middleware.WhiteNoiseMiddleware',]

ROOT_URLconf = 'mart.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates','Dirs': [],'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 = 'mart.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3','NAME': BASE_DIR / 'db.sqlite3',}
}


# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',{
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',{
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',{
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',]


# Internationalization
# https://docs.djangoproject.com/en/3.1/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/3.1/howto/static-files/

STATIC_URL = '/static/'

STATICFILES_Dirs = [
    os.path.join(BASE_DIR,'static')
]

MEDIA_URL = '/images/'

MEDIA_ROOT = os.path.join(BASE_DIR,'static/images')


STRIPE_TEST_PUBLIC_KEY = config('STRIPE_TEST_PUBLIC_KEY')
STRIPE_TEST_SECRET_KEY = config('STRIPE_TEST_SECRET_KEY')
STRIPE_WEBHOOK_SECRET =""


REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.BasicAuthentication'
    ],'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination','PAGE_SIZE': 10
}

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesstorage'

logoUT_REDIRECT_URL = 'store'

django_heroku.settings(locals())

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...