2011-05-24 25 views
4

我用django + wsgi構建了一個很好的開發和生產工具。唯一的問題是,當我對buildout.cfg進行更改或添加並且必須運行bin/buildout時,網站將從buildout開始到結束時間離線。這可能需要5分鐘以上。部署到生產,建立和停機時間最短?

有沒有辦法在生產中正常運行buildout?也許我不知道這個參數會運行構建,而不先卸載所有內容?此網站正在一個Web服務器上運行。負載均衡器和額外的Web服務器將是一個不錯的解決方案,但在這一點上不可行。

歡迎對我的構建腳本提出任何其他意見/建議/批評。

謝謝!

這裏是我的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} 

回答

4

擴建將只更新配置已更改(或一個愚蠢的配方實現的情況下)的部分。一種選擇是將構建配置複製/簽出到新位置重新運行構建,然後停止舊實例,然後在新安裝上重新啓動實例。在某些情況下,我們保持像

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

這裏「當前」是一個符號鏈接到當前的「buildout_」安裝設備。

當然,在構建階段您可以在負載平衡器後面運行多個實例,從平衡器中取出實例,這是一個選項。

+0

優秀!這正是我所期待的! – 2011-05-24 15:27:14