Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 768
holms Avatar asked Feb 12 '16 02:02

holms


1 Answers

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.

like image 177
Nicola Iarocci Avatar answered Sep 29 '22 18:09

Nicola Iarocci