heroku应用程序是否必须与django项目共享同一个名称?

时间:2018-01-15 14:00:19

标签: python django heroku

我正在尝试部署一个以django-admin startproject workout开头的应用。几个月后,是时候部署,workout不是heroku应用程序的可用名称。因此,我决定shworkout。现在,我遇到了部署问题。看一下这个追溯:

2018-01-15T13:50:49.922410+00:00 heroku[web.1]: Starting process with command `gunicorn shworkout.wsgi --log-file -`
2018-01-15T13:50:52.274803+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-01-15T13:50:52.275393+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [4] [INFO] Listening at: http://0.0.0.0:57296 (4)
2018-01-15T13:50:52.275484+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [4] [INFO] Using worker: sync
2018-01-15T13:50:52.278566+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [8] [INFO] Booting worker with pid: 8
2018-01-15T13:50:52.283407+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [8] [ERROR] Exception in worker process
2018-01-15T13:50:52.283421+00:00 app[web.1]: Traceback (most recent call last):
2018-01-15T13:50:52.283428+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-01-15T13:50:52.283430+00:00 app[web.1]:     worker.init_process()
2018-01-15T13:50:52.283431+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-01-15T13:50:52.283433+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-01-15T13:50:52.283432+00:00 app[web.1]:     self.load_wsgi()
2018-01-15T13:50:52.283434+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2018-01-15T13:50:52.283443+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-01-15T13:50:52.283441+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-01-15T13:50:52.283442+00:00 app[web.1]:     self.callable = self.load()
2018-01-15T13:50:52.283446+00:00 app[web.1]:     return util.import_app(self.app_uri)
2018-01-15T13:50:52.283448+00:00 app[web.1]:     __import__(module)
2018-01-15T13:50:52.283444+00:00 app[web.1]:     return self.load_wsgiapp()
2018-01-15T13:50:52.283445+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-01-15T13:50:52.283449+00:00 app[web.1]: ModuleNotFoundError: No module named 'shworkout'
2018-01-15T13:50:52.315187+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-01-15T13:50:52.283447+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-01-15T13:50:52.283527+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [8] [INFO] Worker exiting (pid: 8)
2018-01-15T13:50:52.315111+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [4] [INFO] Shutting down: Master
2018-01-15T13:50:52.401600+00:00 heroku[web.1]: Process exited with status 3
2018-01-15T13:50:52.415493+00:00 heroku[web.1]: State changed from starting to crashed

File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-01-15T13:50:52.283449+00:00 app[web.1]: ModuleNotFoundError: No module named 'shworkout'

最引人注目的是什么。我猜是这样的:gunicorn正在寻找一个wsgi.py文件(它在/workout中),但它正在错误的地方寻找它,即一个名为/shworkout的文件夹。我的项目中不存在这样的文件夹。 shworkout只是myoku 上我的应用的名称。

那么,这是正确的解释吗?该怎么办呢?如果我错了,这里到底发生了什么?

Procfile

web: gunicorn shworkout.wsgi --log-file -

我应该将shworkout更改为workout吗?

wsgi.py

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "workout.settings.production")

application = get_wsgi_application()

1 个答案:

答案 0 :(得分:2)

我使用的是错误的Procfile。改变自:

web: gunicorn shworkout.wsgi --log-file -

web: gunicorn workout.wsgi --log-file -

说明:

Procfile应指向wsgi.py文件的位置,该文​​件位于/workout,而不是/shworkout