简体   繁体   中英

Deploying Django with gunicorn and buildout

I wrote a little Django app, using a websockets library (gevent-socketio) and building a virtual environment with buildout. Currently, for serving I have a custom command, that constructs the SocketIOServer class, just like here [1]. Doing it with gunicorn as it says in the docs isn't a difficult task.

So, I would like to use gunicorn as server, my question is about including gunicorn in the buildout.cfg, in order when gunicorn starts, it starts with all the modules existing in the virtualenv (PYTHONPATH).

Is there a recipe for gunicorn that can create a binary under ./bin/? I haven't found much information about buildout+gunicorn.

My buildout.cfg:

[buildout]
parts = django
newest = false
versions = versions
eggs = django 
         redis 
         gevent 
         gevent-websocket 
         gevent-socketio 
         greenlet 
         django-extensions 
         gunicorn

extensions = mr.developer
auto-checkout = *
sources-dir = external

[sources]
gevent = git git://github.com/gevent/gevent.git
gevent-websocket = hg https://bitbucket.org/Jeffrey/gevent-websocket
gevent-socketio = git git://github.com/abourget/gevent-socketio.git
redis = git https://github.com/andymccurdy/redis-py.git

[versions]
django = 1.4

[django]
recipe = djangorecipe
settings = development
eggs = ${buildout:eggs}
extra-paths = 
project = cacho_site

Thanks!

[1] http://gevent-socketio.readthedocs.org/en/latest/server_integration.html#django-runserver

Since the buildout version 2.1.1 you can create a gunicorn script, see https://pypi.python.org/pypi/djangorecipe/2.1.1

than you can simply bin/gunicorn and the rest of the arguments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM