Reputation: 43
I'm trying to deploy a django app using gunicorn and nginx based on this tutorial:
But im having some trouble getting my gunicorn to work properly,
This is my /etc/init/gunicorn.conf:
description "Gunicorn application server handling myproject"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid me
setgid www-data
exec myprojectenv/bin/gunicorn --workers 3 --bind unix:/myproject/myproject.sock myproject.wsgi:application
When in my virtualenv i run:
gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application
everything is ok. But every time i start gunicorn i get this error in my gunicorn error log:
ImportError: No module named 'myproject'
I checked every possible option, but nothing changed. Is there anything im missing out? Thanks in advance.
EDIT:
I added a chdir line before exec:
chdir /myproject/myprojectenv
Im still getting
ImportError: No module named 'myproject'
Upvotes: 1
Views: 829
Reputation: 599946
When you run this manually, you are presumably already in the correct directory, so gunicorn can find the myproject.wsgi module. But when running under upstart, it won't be in that directory, so will have no idea where to find the file.
You can solve this by putting chdir /path/to/my/virtualenv
before the exec
line.
Upvotes: 1