【发布时间】:2021-08-09 01:33:22
【问题描述】:
我不清楚在 Heroku 的 Django 应用程序中将 Procfile 保存在哪里 我的应用文件结构是这样的:
coding_site
coding_site
wsgi.py
settings.py
Procfile2
readME.md
Procfile1
other_files
我应该保存在 Procfile1 还是 Procfile2 的位置?
我的 Procfile 看起来像这样:
在位置 Procfile1
web: gunicorn coding_site.coding_site.wsgi --log-file -
在 Procfile2 中
web: gunicorn coding_site.wsgi --log-file -
我遇到的错误
使用 Procfile1 位置
2021-05-19T18:40:51.423744+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET
path="/admin" host=coding-club-jaya.herokuapp.com request_id=71078218-39b0-4b7f-a817-7093078baa08
fwd="123.201.77.16" dyno= connect= service= status=503 bytes= protocol=https
使用 Procfile2 位置
2021-05-19T17:49:21.981719+00:00 heroku[router]: at=error code=H14 desc="No web processes running"
method=GET path="/admin" host=coding-club-jaya.herokuapp.com request_id=a47a58e6-4513-44a4-88aa-4425470d8465
fwd="123.201.77.16" dyno= connect= service= status=503 bytes= protocol=https
顺便说一句:
我更改了 settings.py 文件,如不同教程中所示
这里是 setting.py 代码中所做的更改
import django_heroku
import dj_database_url
***
MIDDLEWARE =[**, 'whitenoise.middleware.WhiteNoiseMiddleware', **]
***
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'ciba',
}
}
***
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
os.makedirs(STATIC_ROOT, exist_ok=True)
os.makedirs(STATICFILES_DIRS[0], exist_ok=True)
# Activate Django-Heroku.
django_heroku.settings(locals())
如果这里需要我的 requirements.txt 文件
gunicorn==20.1.0
whitenoise==5.2.0
django-heroku==0.3.1
Django==3.0.2
requests==2.22.0
sqlparse==0.2.4
dj-database-url==0.5.0
dj-static==0.0.6
docopt==0.6.2
psycopg2
python-decouple
gitignore==0.0.8
pytz==2018.9
static3==0.7.0
当我检查 heroku 中的日志文件时,我发现了这个
2021-05-19T19:35:30.621629+00:00 app[web.1]: ModuleNotFoundError: No module named 'coding_site.settings'
2021-05-19T19:35:30.623811+00:00 app[web.1]: [2021-05-19 19:35:30 +0000] [7] [INFO] Worker exiting (pid: 7)
2021-05-19T19:36:00.748054+00:00 app[web.1]: [2021-05-19 19:36:00 +0000] [4] [INFO] Shutting down: Master
2021-05-19T19:36:00.748553+00:00 app[web.1]: [2021-05-19 19:36:00 +0000] [4] [INFO] Reason: Worker failed to boot.
你可能会发现它很有用
请帮忙,我所有的工作都完成了,卡在最后一步(这是我第一次部署)
谢谢!
【问题讨论】:
标签: python-3.x django heroku django-deployment