0

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>
Community
  • 1
  • 1
Amanda
  • 12,099
  • 17
  • 63
  • 91

1 Answers1

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.

georgebrock
  • 28,393
  • 13
  • 77
  • 72
  • Hmm. I do have a file, `newsdiffs/wsgi.py` but `heroku local` says "No module named newsdiffs.wsgi" (Note: updated my question to clarify that.) – Amanda Sep 28 '15 at 01:05
  • Can you run `gunicorn newsdiffs.wsgi` without `heroku local`? – georgebrock Sep 28 '15 at 02:10
  • There's not much to go on in that error. There might be something helpful in one of these: http://stackoverflow.com/questions/24488891/gunicorn-errors-haltserver-haltserver-worker-failed-to-boot-3-django or http://stackoverflow.com/questions/24639907/gunicorn-errors-haltserver-haltserver-worker-failed-to-boot-3 – georgebrock Sep 28 '15 at 11:46