Django app crashing on Heroku
Question: I am trying to port an app that runs fine on my computer using runserver to
Heroku. I am new to Django and have never deployed an app on Heroku before. I
am not sure what I am missing.

Here is the heroku error:

    
    
    2015-01-18T00:59:22.855761+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
    
    2015-01-18T00:59:22.855803+00:00 app[web.1]:     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
    
    2015-01-18T00:59:22.855877+00:00 app[web.1]:     super(Application, self).run()
    
    2015-01-18T00:59:22.856001+00:00 app[web.1]:     self.manage_workers()
    
    2015-01-18T00:59:22.856023+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
    
    2015-01-18T00:59:22.856111+00:00 app[web.1]:     self.spawn_workers()
    
    2015-01-18T00:59:22.856132+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 542, in spawn_workers
    
    2015-01-18T00:59:22.855899+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 71, in run
    
    2015-01-18T00:59:22.856230+00:00 app[web.1]:     time.sleep(0.1 * random.random())
    
    2015-01-18T00:59:22.856252+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 209, in handle_chld
    
    2015-01-18T00:59:22.856491+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
    
    2015-01-18T00:59:22.856303+00:00 app[web.1]:     self.reap_workers()
    
    2015-01-18T00:59:22.856324+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
    
    2015-01-18T00:59:22.856408+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
    
    2015-01-18T00:59:22.855680+00:00 app[web.1]: Traceback (most recent call last):
    2015-01-18T00:59:22.855699+00:00 app[web.1]:   File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
    
    2015-01-18T00:59:22.855732+00:00 app[web.1]:     sys.exit(run())
    
    2015-01-18T00:59:22.855825+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 185, in run
    
    2015-01-18T00:59:22.855932+00:00 app[web.1]:     Arbiter(self).run()
    
    2015-01-18T00:59:22.855953+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 169, in run
    
    2015-01-18T00:59:23.546103+00:00 heroku[web.1]: Process exited with status 1
    
    2015-01-18T00:59:23.550975+00:00 heroku[web.1]: State changed from starting to crashed
    
    2015-01-18T00:59:25.538419+00:00 heroku[api]: Scale to web=1 by thebucketmoney@gmail.com
    
    2015-01-18T01:00:20.825543+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" 
    

my wsgi file looks like this:

    
    
    import os
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ssbo.settings")
    
    from django.core.wsgi import get_wsgi_application
    from whitenoise.django import DjangoWhiteNoise
    from dj_static import Cling
    
    application = Cling(get_wsgi_application())
    application = DjangoWhiteNoise(application)
    

I have created several settings files (base, local, staging, production). I am
using staging on heroku by setting
DJANGO_SETTINGS_MODULE="ssbo.settings.staging"

Staging file:

    
    
    DEBUG = True
    TEMPLATE_DEBUG = True
    WSGI_APPLICATION = 'ssbo.wsgi.application'
    SESSION_COOKIE_AGE = 300
    SECRET_KEY = get_env_variable("SECRET_KEY")
    
    import dj_database_url
    DATABASES = {}
    DATABASES['default'] =  dj_database_url.config()
    

base settings file:

    
    
    STATIC_ROOT = 'staticfiles'
    STATIC_URL = '/static/'
    
    STATICFILES_DIRS = (
        os.path.join(BASE_DIR, 'static'),
    )
    
    STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
    BASE_DIR = os.path.join(os.path.dirname(__file__), '..')
    

requirements.txt:

    
    
    Django==1.7.3
    psycopg2==2.5.4
    stripe==1.19.0
    gunicorn==19.1.1
    dj-database-url==0.3.0
    whitenoise==1.0.6
    dj-static==0.0.6
    

Procfile:

    
    
    web: gunicorn ssbo.wsgi
    

Project structure:

    
    
    ssbo
      app
        migrations
        static
          app
        templates
          app
        admin.py
        forms.py
        models.py
        views.py
      ssbo
        settings
          base.py
          local.py
          production.py
          staging.py
        urls.py
        wsgi.py
      manage.py
    


Answer: Running the gunicorn server with the --preload flag revealed the problem. The
Procfile had an incorrect argument.

