编程语言
首页 > 编程语言> > python – 通过buildout和最短的停机时间部署到生产?

python – 通过buildout和最短的停机时间部署到生产?

作者:互联网

我有一个django wsgi的扩建,它在开发和生产方面做得很好.唯一的问题是,当我对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}

解决方法:

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

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

其中’current’是当前’buildout_’安装的符号链接.

当然:在负载均衡器后面运行多个实例,在构建阶段将实例从平衡器中取出是一个选项.

标签:python,django,deployment,buildout
来源: https://codeday.me/bug/20190626/1295868.html