【问题标题】:Deploying Django with gunicorn and buildout使用 gunicorn 和 buildout 部署 Django
【发布时间】:2012-12-04 21:37:27
【问题描述】:

我编写了一个小 Django 应用程序,使用 websockets 库 (gevent-socketio) 并使用 buildout 构建虚拟环境。目前,为了提供服务,我有一个自定义命令,它构造 SocketIOServer 类,就像here [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

【问题讨论】:

  • 我看到一个 blog post 在构建中设置 gunicorn,这有帮助吗?
  • 博客帖子的链接不再起作用....但是对解决方案非常感兴趣,您能否在此处添加它作为答案,并接受您自己的答案?提前致谢。

标签: python django deployment buildout gunicorn


【解决方案1】:

从 buildout 版本 2.1.1 开始,您可以创建 gunicorn 脚本,请参阅 https://pypi.python.org/pypi/djangorecipe/2.1.1

您可以简单地使用 bin/gunicorn 和其他参数。

【讨论】:

    猜你喜欢
    • 2011-04-20
    • 2012-08-22
    • 2020-12-26
    • 1970-01-01
    • 2013-12-08
    • 2015-08-01
    • 2015-06-02
    • 2014-03-31
    • 2020-04-06
    相关资源
    最近更新 更多