Running Django projects from virtualenv with Gunicorn >=19 -
i saw news on docs.gunicorn.org gunicorn v.19:
deprecations
run_gunicorn, gunicorn_django , gunicorn_paster deprecated , removed in next release. use gunicorn command instead.
i run applications virtual environments, created virtualenv command in supervisor:
[program:my_app] command=/var/www/.virtualenvs/my_app/bin/gunicorn_django -c /var/www/my_app/conf/gunicorn.conf.py user=www-data group=www-data daemon=false debug=false autostart=true autorestart=true redirect_stderr=true stdout_logfile=/var/www/my_app/log/supervisor.log
how should change settings run projects new version gunicorn?
the command line should changed following
command=/var/www/.virtualenvs/my_app/bin/gunicorn my_app.wsgi:application -c /var/www/my_app/conf/gunicorn.conf.py
this assuming have file my_app/wsgi.py. since django 1.4, startproject has generated wsgi.py file part of project. i'd assume have this, if not can use following snippet create file.
import os os.environ.setdefault("django_settings_module", "my_app.settings") django.core.wsgi import get_wsgi_application application = get_wsgi_application()
see https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
you may need ensure my_app directory in pythonpath if not already, or errors.
to test out standalone on command line new django project, following should work assuming have django , gunicorn installed in current environment.
django-admin.py startproject myproject cd myproject export pythonpath=$pythonpath:. gunicorn myproject.wsgi:application -b localhost:8008
Comments
Post a Comment