问题
I'm trying to assemble some of the missing pieces in my understanding of how to deploy a Django App to heroku, so that I can launch an instance of Newsdiffs on Heroku.
When I walk through the instructions for running Django on Heroku they have you add a line to Procfile
that reads thus: web: gunicorn hellodjango.wsgi --log-file -
But there's no actual file named "hellodjango.wsgi" so ... in that tutorial, where is the "hellodjango.wsgi" module created?
And, perhaps more to the point, why is heroku local
balking that I have web.1 | : No module named newsdiffs.wsgi
when newdsdiffs/wsgi.py
definitely exists.
I can launch the app locally with python website/manage.py runserver
but if I do gunicorn newsdiffs.wsgi
I get the following, which doesn't include any obvious indications (to my eye) of what I'm doing wrong:
(venv)amanda@mona:newsdiffs$ gunicorn newsdiffs.wsgi
Traceback (most recent call last):
File "/home/amanda/Public/newsdiffs/venv/bin/gunicorn", line 11, in <module>
sys.exit(run())
File "/home/amanda/Public/newsdiffs/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/home/amanda/Public/newsdiffs/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 185, in run
super(Application, self).run()
File "/home/amanda/Public/newsdiffs/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 71, in run
Arbiter(self).run()
File "/home/amanda/Public/newsdiffs/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 169, in run
self.manage_workers()
File "/home/amanda/Public/newsdiffs/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
self.spawn_workers()
File "/home/amanda/Public/newsdiffs/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 542, in spawn_workers
time.sleep(0.1 * random.random())
File "/home/amanda/Public/newsdiffs/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 209, in handle_chld
self.reap_workers()
File "/home/amanda/Public/newsdiffs/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
回答1:
The gunicorn
command takes the name of a Python module, not a path to a file. If hellodjango.wsgi
is the name of the Python module, the corresponding file will be hellodjango/wsgi.py
or hellodjango/wsgi/__init__.py
.
This is the same syntax used to refer to a module when importing it, e.g. you would import * from hellodjango.wsgi
to get access to the things defined in hellodjango/wsgi.py
.
The django-admin startproject
command will create a wsgi.py
file in the same directory as the project's settings.py
and urls.py
files.
来源:https://stackoverflow.com/questions/32814227/where-is-hellodjango-wsgi