Reputation: 351
Ok, I'm trying to run a django app with gunicorn, but nothing seems to make it work, my app folder structure looks like this:
/home/web/app/
appenv/
dtest/
static/
db.sqlite3
manage.py
appenv contains my virtual environment and inside dtest I have the file wsgi.py which contains:
import os
import sys
sys.path.append('/home/web/app/dtest')
sys.path.append('/home/web/app')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dtest.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Then I try to run gunicorn like this:
gunicorn wsgi.py -b 0.0.0.0:9999
But I get the error:
[2018-10-09 17:37:46 -0500] [15177] [INFO] Starting gunicorn 19.9.0
[2018-10-09 17:37:46 -0500] [15177] [INFO] Listening at: http://0.0.0.0:9999 (15177)
[2018-10-09 17:37:46 -0500] [15177] [INFO] Using worker: sync
[2018-10-09 17:37:46 -0500] [15180] [INFO] Booting worker with pid: 15180
[2018-10-09 22:37:49 +0000] [15180] [ERROR] Exception in worker process
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
Then gunicorn dies ... It must be something in the way my module is getting imported but Im not sure exactly what is it (maybe modifying sys.modules?)
Im using Django version 2.0.9, gunicorn (version 19.9.0), Python 3.4.2 on dietpi (debian 8 Jessie).
[By the way, running python manage.py runserver works just fine]
Upvotes: 0
Views: 2365
Reputation: 384
I met gunicorn cannot start
issue recently.
After spent quite a of time, I found it's caused by the running user doesn't have write permission to the log file and pid file.
Hope it can help for who made the similar mistake.
Upvotes: 0
Reputation: 351
Ok it was a silly error, it was the way I was starting gunicorn, this one does the trick:
gunicorn wsgi:application -b 127.0.0.1:9999
(I was missing the :application part)
Upvotes: 1