使用buildout和最小停机时间部署到生产环境?

4
我有一个包括django和wsgi的buildout环境,在开发和生产环境中都可以正常使用。唯一的问题是,当我更改或添加buildout.cfg文件并需要运行bin/buildout时,从buildout开始到完成期间,网站会处于离线状态。这可能需要5分钟以上的时间。
有没有一种优雅地在生产环境中运行buildout的方法?也许有些参数我不知道,可以在不先卸载所有内容的情况下运行buildout?该站点正在单个web服务器上运行。负载均衡器和额外的Web服务器是一个不错的解决方案,但目前不可行。
欢迎任何其他关于我的buildout脚本的评论/建议/批评。
谢谢!
以下是我的buildout.cfg:
[buildout]
download-cache = downloads
unzip = true
parts =
    scripts
    django
    djangoprod

eggs = 
    ${scripts:eggs} 
    ${pipscripts:eggs}

[scripts]
recipe = zc.recipe.egg
unzip = true
download-cache = ${buildout:download-cache}
eggs =
    ipython
    docutils
    feedparser
    pygments
    South
    django-grappelli
    django-extensions
    django-mobile
    django-photologue
    django-filebrowser
    django-indexer
    django-paging
    django-templatetag-sugar
    django-sentry
    MySQL-python

find-links =
    http://dist.repoze.org/
    http://github.com/
    http://bitbucket.org/
    http://googlecode.com/
    http://surfnet.dl.sourceforge.net/

[pipscripts]
recipe = gp.recipe.pip
unzip = true
download-cache = ${buildout:download-cache}
editables = 
    hg+https://bitbucket.org/ubernostrum/django-registration#egg=django_registration
    git://github.com/jtauber/django-mailer.git#egg=django_mailer
eggs = 
    django-registration
    django-mailer
    PIL
install =
    http://effbot.org/downloads/Imaging-1.1.7.tar.gz

[django]
recipe = djangorecipe
download-cache = ${buildout:download-cache}
eggs = ${buildout:eggs}
version = 1.3
project = project

[djangoprod]
recipe = djangorecipe
download-cache = ${django:download-cache}
version = ${django:version}
settings = production
wsgi = true
eggs = ${django:eggs}
project = ${django:project}
1个回答

4

Buildout只会更新配置更改的部分(或者在愚蠢的配方实现情况下)。一种选项是将buildout配置复制/检出到新位置,重新运行buildout,然后停止旧实例,再在新安装上重启实例。在某些情况下,我们维护像...

/data/buildout_<date1>
/data/buildout_<date2>
/data/current

这里的“current”是指当前“buildout_”安装的符号链接。

当然,你可以在负载均衡器后运行多个实例,在构建期间将一个实例从负载均衡器中删除也是一种选择。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接