gunicorn fails to launch python-eve

Here’s settings.py

root@00d72ee95c2d:/var/www/eve-auth# cat settings.py
DOMAIN = {'people': {}}

And here’s run.py

  • Sending email using smtplib in ubuntu docker throws “421 4.3.2 Connection rate limit exceeded”
  • windows docker on vmwarevsphere
  • How can I test with serverspec that Jenkins is running in a jenkins docker container?
  • The git source is not yet checked out when running Docker
  • docker: freeze library dependencies
  • Spark UI is inaccessible from host for sequenceiq/spark:1.6.0
  • from eve import Eve
    app = Eve()
    
    if __name__ == '__main__':
        app.run()
    

    It works when I run it standalone:

    root@00d72ee95c2d:/var/www/eve-auth# python run.py
     * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
    

    But fails to run when I launch it through gunicorn:

    root@00d72ee95c2d:/var/www/eve-auth# gunicorn -b 0.0.0.0:5000 run:app
    [2016-02-12 02:07:22 +0000] [20] [INFO] Starting gunicorn 19.4.5
    [2016-02-12 02:07:22 +0000] [20] [INFO] Listening at: http://0.0.0.0:5000 (20)
    [2016-02-12 02:07:22 +0000] [20] [INFO] Using worker: sync
    [2016-02-12 02:07:22 +0000] [23] [INFO] Booting worker with pid: 23
    [2016-02-12 02:07:22 +0000] [23] [ERROR] Exception in worker process:
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/site-packages/eve/flaskapp.py", line 246, in validate_domain_struct
        domain = self.config['DOMAIN']
    KeyError: 'DOMAIN'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
        worker.init_process()
      File "/usr/local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 122, in init_process
        self.load_wsgi()
      File "/usr/local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
        self.wsgi = self.app.wsgi()
      File "/usr/local/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
        self.callable = self.load()
      File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
        return self.load_wsgiapp()
      File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
        return util.import_app(self.app_uri)
      File "/usr/local/lib/python3.5/site-packages/gunicorn/util.py", line 357, in import_app
        __import__(module)
      File "/var/www/eve-auth/run.py", line 2, in <module>
        app = Eve()
      File "/usr/local/lib/python3.5/site-packages/eve/flaskapp.py", line 135, in __init__
        self.validate_domain_struct()
      File "/usr/local/lib/python3.5/site-packages/eve/flaskapp.py", line 248, in validate_domain_struct
        raise ConfigException('DOMAIN dictionary missing or wrong.')
    eve.exceptions.ConfigException: DOMAIN dictionary missing or wrong.
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/site-packages/eve/flaskapp.py", line 246, in validate_domain_struct
        domain = self.config['DOMAIN']
    KeyError: 'DOMAIN'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
        worker.init_process()
      File "/usr/local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 122, in init_process
        self.load_wsgi()
      File "/usr/local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
        self.wsgi = self.app.wsgi()
      File "/usr/local/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
        self.callable = self.load()
      File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
        return self.load_wsgiapp()
      File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
        return util.import_app(self.app_uri)
      File "/usr/local/lib/python3.5/site-packages/gunicorn/util.py", line 357, in import_app
        __import__(module)
      File "/var/www/eve-auth/run.py", line 2, in <module>
        app = Eve()
      File "/usr/local/lib/python3.5/site-packages/eve/flaskapp.py", line 135, in __init__
        self.validate_domain_struct()
      File "/usr/local/lib/python3.5/site-packages/eve/flaskapp.py", line 248, in validate_domain_struct
        raise ConfigException('DOMAIN dictionary missing or wrong.')
    eve.exceptions.ConfigException: DOMAIN dictionary missing or wrong.
    [2016-02-12 02:07:22 +0000] [23] [INFO] Worker exiting (pid: 23)
    [2016-02-12 02:07:22 +0000] [20] [INFO] Shutting down: Master
    [2016-02-12 02:07:22 +0000] [20] [INFO] Reason: Worker failed to boot.
    

    I couldn’t find any documentation about gunicorn and python-eve… so I’m not sure where to dig from here.

  • JDBC driver class not loading for JAVA app when it connects to Postgres in Docker
  • Read local file system with Java from Docker container
  • How to deploy Apache Solr 5x into the Jelastic cloud?
  • Using Ansible,Jenkins and docker to build fast test environments
  • Docker search command with criteria shows inconsistent results
  • run ionic framework into docker does not create localy folder/files
  • 2 Solutions collect form web for “gunicorn fails to launch python-eve”

    I never ran Eve on Gunicorn. However, Eve being a Flask subclass, most things that work with Flask, work for Eve too.

    According to Flask documentation you run Flask/Eve on Gunicorn like this:

    gunicorn myproject:app
    

    Hope this helps.

    The problem is that Eve uses a relative path to look for settings.py, the quickest fix is to use an absolute path:

    import os
    from eve import Eve
    
    app = Eve(__name__, settings=os.path.abspath('settings.py'))
    
    if __name__ == '__main__':
        app.run()
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.