Python + Django debug startup on WSGI - django

I'm facing a crash launching with GUNICORN my App on MacOsX Sierra.
Is there any way to better understand the error message? Like to know which dependency is missing or something like that?
I searched online for more log-level info but, right now, the error is not easy to understand.
I report the error if somebody has any clue or any tool to drill down the exception and find it out!
I believe you did
I Already tried this solution and django-haystack was already there
pip install haystack
pip uninstall haysatck
pip install django-haystack
Thanks in advance
gunicorn direttoo.wsgi:application --workers 1 --bind 127.0.0.1:8001 --log-level Info
[2017-03-24 12:30:51 +0100] [3304] [INFO] Starting gunicorn 19.6.0
[2017-03-24 12:30:51 +0100] [3304] [INFO] Listening at: http://127.0.0.1:8001 (3304)
[2017-03-24 12:30:51 +0100] [3304] [INFO] Using worker: sync
[2017-03-24 12:30:51 +0100] [3307] [INFO] Booting worker with pid: 3307
[2017-03-24 11:30:51 +0000] [3307] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
worker.init_process()
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
self.wsgi = self.app.wsgi()
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/gunicorn/util.py", line 357, in import_app
__import__(module)
File "/Users/diegobanovaz/Projects/direttoo/direttoo/wsgi.py", line 36, in <module>
application = get_wsgi_application()
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup()
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/diegobanovaz/Projects/direttoo/env/lib/python2.7/site-packages/haystack/__init__.py", line 56, in <module>
maxnofile[1]))
ValueError: current limit exceeds maximum limit
[2017-03-24 11:30:51 +0000] [3307] [INFO] Worker exiting (pid: 3307)
[2017-03-24 12:30:51 +0100] [3304] [INFO] Shutting down: Master
[2017-03-24 12:30:51 +0100] [3304] [INFO] Reason: Worker failed to boot.

Related

Google Cloud Platform: ImportError: No module named 'google.api.core' on deploy

This is the error I receive while I try to deploy using gcloud app deploy. I have previously successfully deployed the same app. I am able to run the app in local machine, but receives the error on deploy
the traceback:
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
[2017-08-25 10:50:23 +0000] [1] [INFO] Starting gunicorn 19.7.1
[2017-08-25 10:50:23 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[2017-08-25 10:50:23 +0000] [1] [INFO] Using worker: sync
[2017-08-25 10:50:23 +0000] [7] [INFO] Booting worker with pid: 7
[2017-08-25 10:50:23 +0000] [7] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/env/lib/python3.5/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/env/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/env/lib/python3.5/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/env/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/env/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/env/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/env/lib/python3.5/site-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
File "/home/vmagent/app/main.py", line 19, in <module>
app = bookshelf.create_app(config)
File "/home/vmagent/app/bookshelf/__init__.py", line 49, in create_app
model = get_model()
File "/home/vmagent/app/bookshelf/__init__.py", line 107, in get_model
from . import model_datastore
File "/home/vmagent/app/bookshelf/model_datastore.py", line 16, in <module>
from google.cloud import datastore
File "/env/lib/python3.5/site-packages/google/cloud/datastore/__init__.py", line 61, in <module>
from google.cloud.datastore.client import Client
File "/env/lib/python3.5/site-packages/google/cloud/datastore/client.py", line 33, in <module>
from google.cloud.datastore.query import Query
File "/env/lib/python3.5/site-packages/google/cloud/datastore/query.py", line 19, in <module>
from google.api.core import page_iterator
ImportError: No module named 'google.api.core'
[2017-08-25 10:50:23 +0000] [7] [INFO] Worker exiting (pid: 7)
[2017-08-25 10:50:24 +0000] [1] [INFO] Shutting down: Master
[2017-08-25 10:50:24 +0000] [1] [INFO] Reason: Worker failed to boot.
tl;dr: Upgrade your google-cloud to 0.27, and it should fix things.
I believe this is a bug with the new google-cloud dependencies. In my case, google-cloud==0.25 was pulling in these dependencies in its setup.py:
'google-cloud-core >= 0.24.0, < 0.25dev',
'google-cloud-datastore >= 1.0.0, < 2.0dev',
Just recently on 8/24 (a day before this issue was filed), the google-cloud-datastore package was updated to 1.3.0.
Unfortunately, google-cloud-datastore 1.3.0 is depending on a newer version of google-cloud-core:
'google-cloud-core >= 0.27.0, < 0.28dev',
But it seems this versioning conflict is unresolved/unwarned by pip, which uses the older version. But google-cloud-datastore wants to from google.api.core import page_iterator, even though google.api.core, which wasn't added until 0.27.0, and then everything breaks.
I believe the "bug" is in the overload broad dependency in google-cloud===0.25 (or possibly whatever version you are using).
I believe the "fix" for us is to upgrade to the latest version of google-cloud=0.27.
Though the "proper fix" is for google-cloud to improve their versioning dependencies, and not be so broad, or risk breaking backwards compatibility with already-published modules.

gunicorn failed to start worker process while working withDjango app

Good Afternoon, I am developing a Django App and trying to develop it using gunicorn and nginx as web server loadbalancer for http. when trying to start gunicorn from within an venv (the app is being developed within a venv )using
../bin/gunicorn biblio_cfv.wsgi: application
I get these errors
[2016-10-14 16:37:13 -0400] [22618] [INFO] Starting gunicorn 19.6.0
[2016-10-14 16:37:13 -0400] [22618] [INFO] Listening at: http://127.0.0.1:8000 (22618)
[2016-10-14 16:37:13 -0400] [22618] [INFO] Using worker: sync
[2016-10-14 16:37:13 -0400] [22621] [INFO] Booting worker with pid: 22621
[2016-10-14 20:37:22 +0000] [22621] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
worker.init_process()
File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
self.wsgi = self.app.wsgi()
File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/util.py", line 368, in import_app
app = eval(obj, mod.__dict__)
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
I checked the file util.py withon gunicorn code and found nothin wrong
here is the function of the code that gives the error.
def import_app(module):
parts = module.split(":", 1)
if len(parts) == 1:
module, obj = module, "application"
else:
module, obj = parts[0], parts[1]
try:
__import__(module)
except ImportError:
if module.endswith(".py") and os.path.exists(module):
msg = "Failed to find application, did you mean '%s:%s'?"
raise ImportError(msg % (module.rsplit(".", 1)[0], obj))
else:
raise
mod = sys.modules[module]
try:
app = eval(obj, mod.__dict__)
except NameError:
raise AppImportError("Failed to find application: %r" % module)
if app is None:
raise AppImportError("Failed to find application object: %r" % obj)
if not callable(app):
raise AppImportError("Application object must be callable.")
return app
Please could anyone shed any light on this. Thanks in advance.
I know this was asked a long time ago, but I resolved mine just now.
Just 'pip install gunicorn' in that virtual environment

Problems configuring deployment with Heroku/gunicorn/django

I'm trying to run my django application on heroku.
Folder structure:
app/
Procfile
docs/
...
project/
manage.py
wsgi.py
<django apps>
Procfile
web: gunicorn --pythonpath="$PWD/project" wsgi:application --log-file=-
Error I'm getting:
2015-02-16T16:05:00.646316+00:00 heroku[web.1]: Starting process with command `gunicorn --pythonpath="$PWD/project" wsgi:application --log-file=-`
2015-02-16T16:05:02.697633+00:00 app[web.1]: [2015-02-16 16:05:02 +0000] [3] [INFO] Listening at: http://0.0.0.0:44846 (3)
2015-02-16T16:05:02.709567+00:00 app[web.1]: [2015-02-16 16:05:02 +0000] [9] [INFO] Booting worker with pid: 9
2015-02-16T16:05:02.696968+00:00 app[web.1]: [2015-02-16 16:05:02 +0000] [3] [INFO] Starting gunicorn 19.1.1
2015-02-16T16:05:02.697790+00:00 app[web.1]: [2015-02-16 16:05:02 +0000] [3] [INFO] Using worker: sync
2015-02-16T16:05:02.793753+00:00 app[web.1]: [2015-02-16 16:05:02 +0000] [10] [INFO] Booting worker with pid: 10
2015-02-16T16:05:03.157305+00:00 app[web.1]: Traceback (most recent call last):
2015-02-16T16:05:03.157311+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2015-02-16T16:05:03.157351+00:00 app[web.1]: sys.exit(run())
2015-02-16T16:05:03.157383+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2015-02-16T16:05:03.157461+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2015-02-16T16:05:03.157463+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 185, in run
2015-02-16T16:05:03.157506+00:00 app[web.1]: super(Application, self).run()
2015-02-16T16:05:03.157527+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 71, in run
2015-02-16T16:05:03.157604+00:00 app[web.1]: Arbiter(self).run()
2015-02-16T16:05:03.157607+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 196, in run
2015-02-16T16:05:03.157635+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2015-02-16T16:05:03.157656+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 292, in halt
2015-02-16T16:05:03.157730+00:00 app[web.1]: self.stop()
2015-02-16T16:05:03.157744+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 343, in stop
2015-02-16T16:05:03.157814+00:00 app[web.1]: time.sleep(0.1)
2015-02-16T16:05:03.157836+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 209, in handle_chld
2015-02-16T16:05:03.157887+00:00 app[web.1]: self.reap_workers()
2015-02-16T16:05:03.157908+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
2015-02-16T16:05:03.158009+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2015-02-16T16:05:03.158075+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2015-02-16T16:05:03.904714+00:00 heroku[web.1]: Process exited with status 1
2015-02-16T16:05:03.914410+00:00 heroku[web.1]: State changed from starting to crashed
Update 1
My wsgi.py file
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config")
os.environ.setdefault("DJANGO_CONFIGURATION", "Production")
from configurations.wsgi import get_wsgi_application
application = get_wsgi_application()
Here I am just adding some text because SO has this silly minimum amount of text that must be written in a question. I mean, I do get it that quality needs to be kept, but if the problem is self explanatory why force people to write unneeded text? Thanks and have a great day!
Adding --preload to the gunicorn command in the Procfile will make your Traceback a lot more readable and show you the actual errors.
Exmaple:
gunicorn project.wsgi:application --preload --workers 1
I had a similar problem, after reading he docs for gunicorn, I was able to add
--log-level debug
to the
web: gunicorn project.wsgi:application --log-file -
such that its
web: gunicorn project.wsgi:application --log-file - --log-level debug
In my case the path was also an issue.
Finally found the solution, it was a missing dependency of django-organizations. I find it crazy that there is no way (at least not that I could find) to see any useful error output from heroku. I finally did
heroku run bash --app <app_name>
and then ran the wsgi.py file line by line, finally getting some meaningful error on
from configurations.wsgi import get_wsgi_application # noqa
It was then clear that it's a missing module error, installed it and everything runs perfectly fine.
Change your Procfile to:
web: gunicorn project.wsgi:application --log-file=-
You're missing the project module in the python path to the wsgi.py file.
I solved it. I followed these steps:
Remove all the unused libraries.
Delete requirements.txt file.
Create a new requirements.txt file.
Commit to Git and then deploy on Heroku.

what does this error imply in gunicorn/socketio worker?: AttributeError: socket has no attribute cfg_addr

I run a command line, which is logged here:
running: gunicorn -w 11 --worker-class socketio.sgunicorn.GeventSocketIOWorker --bind=127.0.0.1:8800 --access-logfile - --error-logfile - fbrealtime.wsgi:application
2014-08-03 19:15:20 [4047] [INFO] Starting gunicorn 19.1.0
2014-08-03 19:15:20 [4047] [INFO] Listening at: http://127.0.0.1:8800 (4047)
2014-08-03 19:15:20 [4047] [INFO] Using worker: socketio.sgunicorn.GeventSocketIOWorker
2014-08-03 19:15:20 [4052] [INFO] Booting worker with pid: 4052
2014-08-03 19:15:20 [4053] [INFO] Booting worker with pid: 4053
2014-08-03 19:15:20 [4052] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/home/luismasuelli/.virtualenvs/dj16fbrt/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
worker.init_process()
File "/home/luismasuelli/.virtualenvs/dj16fbrt/local/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 193, in init_process
super(GeventWorker, self).init_process()
File "/home/luismasuelli/.virtualenvs/dj16fbrt/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 120, in init_process
self.run()
File "/home/luismasuelli/.virtualenvs/dj16fbrt/src/gevent-socketio/socketio/sgunicorn.py", line 80, in run
**ssl_args
File "/home/luismasuelli/.virtualenvs/dj16fbrt/src/gevent-socketio/socketio/server.py", line 72, in __init__
address = args[0].cfg_addr[0]
AttributeError: 'socket' object has no attribute 'cfg_addr'
Traceback (most recent call last):
File "/home/luismasuelli/.virtualenvs/dj16fbrt/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
worker.init_process()
File "/home/luismasuelli/.virtualenvs/dj16fbrt/local/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 193, in init_process
super(GeventWorker, self).init_process()
File "/home/luismasuelli/.virtualenvs/dj16fbrt/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 120, in init_process
self.run()
File "/home/luismasuelli/.virtualenvs/dj16fbrt/src/gevent-socketio/socketio/sgunicorn.py", line 80, in run
**ssl_args
File "/home/luismasuelli/.virtualenvs/dj16fbrt/src/gevent-socketio/socketio/server.py", line 72, in __init__
address = args[0].cfg_addr[0]
AttributeError: 'socket' object has no attribute 'cfg_addr'
Why am I getting this error? The command line is the first line of the log. Am I doing something wrong?
It's a django 1.6 application with gevent 1.0.1 and gevent-socketio (git state: master 668d11edbd62052cde1583be1e1d0512c930f16d#) gevent-websocket 0.9.3 and gunicorn 19.1.0.
Apparently this error does not affect when I'm trying to access my application at http://localhost:8800/ but: what does it mean? what will it imply? how can I fix it?

Heroku NameError: name 'application' is not defined

I'm trying to deploy a django app to heroku and it keeps crashing. Does anyone have any idea what I'm doing wrong?
Here is my Procfile:
web: python app/manage.py collectstatic --noinput; gunicorn --workers=4 --bind=0.0.0.0:$PORT app.settings
And here is a snippet from my heroku logs:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process
File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 456, in spawn_worker
self.wsgi = self.app.wsgi()
app = eval(obj, mod.__dict__)
File "<string>", line 1, in <module>
File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 101, in wsgi
File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 24, in load
self.callable = self.load()
return util.import_app(self.app_uri)
NameError: name 'application' is not defined
2014-07-04 17:58:23 [4] [INFO] Starting gunicorn 0.13.4
2014-07-04 17:58:23 [10] [ERROR] Exception in worker process:
worker.init_process()
File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 250, in import_app
2014-07-04 17:58:23 [9] [INFO] Booting worker with pid: 9
2014-07-04 17:58:23 [10] [INFO] Worker exiting (pid: 10)
2014-07-04 17:58:23 [4] [INFO] Listening at: http://0.0.0.0:36148 (4)
2014-07-04 17:58:23 [7] [INFO] Booting worker with pid: 7
It says application not found. well try changing gunicorn
web: gunicorn YourProject.wsgi
I solved my own issue after doing several things, including upgrading my django install and changing my procfile to this:
web: gunicorn app.wsgi --pythonpath app --log-file -