0
votes

hi I'm following this tutorial https://semaphoreci.com/community/tutorials/dockerizing-a-python-django-web-application on how to deploy on docker a Django project,at some point you have to start using gunicorn my start.sh is like this.

#!/bin/bash

#start gunicorn processes

echo "starting gunicorn  for wrappers"

exec gunicorn sparqlwrapper.wsgi.application --bind 0.0.0.0:8000  --workers 5

but when i run the start.sh I get this error

starting gunicorn  for wrappers
[2017-09-28 12:47:05 +0000] [28740] [INFO] Starting gunicorn 19.7.1
[2017-09-28 12:47:05 +0000] [28740] [INFO] Listening at:  http://0.0.0.0:8000 (28740)
[2017-09-28 12:47:05 +0000] [28740] [INFO] Using worker: sync
[2017-09-28 12:47:05 +0000] [28745] [INFO] Booting worker with pid: 28745
[2017-09-28 12:47:05 +0000] [28746] [INFO] Booting worker with pid: 28746
[2017-09-28 12:47:05 +0000] [28747] [INFO] Booting worker with pid: 28747
[2017-09-28 12:47:05 +0000] [28745] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
ImportError: No module named application
[2017-09-28 12:47:05 +0000] [28745] [INFO] Worker exiting (pid: 28745)
[2017-09-28 12:47:05 +0000] [28746] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
ImportError: No module named application
[2017-09-28 12:47:05 +0000] [28746] [INFO] Worker exiting (pid: 28746)
Traceback (most recent call last):
File "/usr/local/bin/gunicorn", line 11, in <module>
sys.exit(run())
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 203, in run
super(Application, self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 72, in run
Arbiter(self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 231, in run
self.halt(reason=inst.reason, exit_status=inst.exit_status)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 344, in halt
self.stop()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 393, in stop
time.sleep(0.1)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 244, in handle_chld
self.reap_workers()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 524, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
[2017-09-28 12:47:05 +0000] [28747] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
ImportError: No module named application
[2017-09-28 12:47:05 +0000] [28747] [INFO] Worker exiting (pid: 28747)

when i run the project with python manage.py runserver 0.0.0.0:8000 it does work so it must be the gunicorn itself

1

1 Answers

4
votes

The application object is not a module; you should use a colon, not a period, to separate it from the module it is in.

exec gunicorn sparqlwrapper.wsgi:application --bind 0.0.0.0:8000  --workers 5