我编写了一个小 Django 应用程序,使用 websockets 库 (gevent-socketio) 并使用 buildout 构建虚拟环境。目前,为了提供服务,我有一个自定义命令,它构造了 SocketIOServer 类,就像这里[1] 一样。正如文档中所说,用 gunicorn 来做这件事并不是一项艰巨的任务。
所以,我想使用 gunicorn 作为服务器,我的问题是关于在 buildout.cfg 中包含 gunicorn,以便在 gunicorn 启动时,它会从 virtualenv(PYTHONPATH)中存在的所有模块开始。
是否有可以在 ./bin/ 下创建二进制文件的 gunicorn 配方?我还没有找到很多关于 buildout+gunicorn 的信息。
我的 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
谢谢!
[1] http://gevent-socketio.readthedocs.org/en/latest/server_integration.html#django-runserver