Created
November 30, 2012 18:11
-
-
Save thomasmassmann/4177477 to your computer and use it in GitHub Desktop.
Dynamic haproxy backends with buildout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[buildout] | |
backends = 4 | |
parts = | |
myapp | |
client | |
haproxy-build | |
haproxy-config | |
supervisor | |
[myapp] | |
recipe = zc.recipe.egg | |
eggs = | |
Paste | |
PasteScript | |
PasteDeploy | |
myapp | |
[client] | |
recipe = z3c.recipe.paster:serve | |
eggs = ${myapp:eggs} | |
ini = | |
[app:myapp] | |
use = egg:myapp | |
[server:main] | |
use = egg:gunicorn#main | |
host = 127.0.0.1 | |
port = %(http_port)s | |
[DEFAULT] | |
# set the name of the zope.conf file | |
zope_conf = ${buildout:parts-directory}/${:_buildout_section_name_}/zope.conf | |
zope.conf = | |
<zodb main> | |
cache-size 5000 | |
<zeoclient> | |
blob-dir ${buildout:directory}/var/blobstorage-${:_buildout_section_name_} | |
cache-size 128MB | |
name zeostorage | |
server 127.0.0.1:8100 | |
shared-blob-dir off | |
storage 1 | |
</zeoclient> | |
</zodb> | |
<eventlog> | |
<logfile> | |
formatter zope.exceptions.log.Formatter | |
path ${buildout:directory}/var/log/${:_buildout_section_name_}.log | |
</logfile> | |
<logfile> | |
formatter zope.exceptions.log.Formatter | |
path STDOUT | |
</logfile> | |
</eventlog> | |
[haproxy-build] | |
recipe = plone.recipe.haproxy | |
url = http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.15.tar.gz | |
target = linux26 | |
[haproxy-conf] | |
recipe = collective.recipe.template[genshi]:genshi | |
input = ${buildout:directory}/templates/haproxy.conf.in | |
output = ${buildout:directory}/etc/haproxy.conf | |
frontend-host = 127.0.0.1 | |
frontend-port = 8000 | |
backends = ${buildout:backends} | |
base_port = 8080 | |
[supervisor] | |
recipe = collective.recipe.supervisor | |
programs = | |
10 client-%(process_num)01d (numprocs=4) ${buildout:directory}/bin/client [http_port=808%(process_num)01d] ${buildout:directory} true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[app:myapp] | |
use = egg:myapp | |
[server:main] | |
use = egg:gunicorn#main | |
host = 127.0.0.1 | |
port = %(http_port)s | |
[DEFAULT] | |
# set the name of the zope.conf file | |
zope_conf = /home/user/app/parts/client/zope.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
... | |
defaults | |
... | |
frontend zeocluster | |
bind 127.0.0.1:8000 | |
default_backend zope | |
backend zope | |
appsession __ac len 32 timeout 1d | |
balance leastconn | |
cookie sid insert nocache indirect | |
option httpchk GET / | |
server client0 127.0.0.1:8080 cookie p0 check maxconn 1 rise 1 | |
server client1 127.0.0.1:8081 cookie p1 check maxconn 1 rise 1 | |
server client2 127.0.0.1:8082 cookie p2 check maxconn 1 rise 1 | |
server client3 127.0.0.1:8083 cookie p3 check maxconn 1 rise 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
... | |
defaults | |
... | |
frontend zeocluster | |
bind ${options['frontend-host']}:${options['frontend-port']} | |
default_backend zope | |
backend zope | |
appsession __ac len 32 timeout 1d | |
balance leastconn | |
cookie sid insert nocache indirect | |
option httpchk GET / | |
{% for i in range(0, int(options.get('backends', '0'))) %} | |
{% python | |
port = int(options.get('base_port', '8080')) + i | |
%} | |
server client${i} 127.0.0.1:${port} cookie p${i} check maxconn 1 rise 1 | |
{% end %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[supervisord] | |
childlogdir = /home/user/app/var/log | |
logfile = /home/user/app/var/log/supervisord.log | |
logfile_maxbytes = 50MB | |
logfile_backups = 10 | |
loglevel = info | |
pidfile = /home/user/app/var/supervisord.pid | |
umask = 022 | |
nodaemon = false | |
nocleanup = false | |
[program:client-%(process_num)01d] | |
command = /home/user/app/bin/client http_port=808%(process_num)01d | |
process_name = client-%(process_num)01d | |
directory = /home/user/app | |
priority = 10 | |
redirect_stderr = true | |
numprocs = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
site-definition /home/user/app/parts/client/site.zcml | |
<zodb main> | |
cache-size 5000 | |
<zeoclient> | |
blob-dir /home/user/app/var/blobstorage-client | |
cache-size 128MB | |
name zeostorage | |
server 127.0.0.1:8100 | |
shared-blob-dir off | |
storage 1 | |
</zeoclient> | |
</zodb> | |
<eventlog> | |
<logfile> | |
formatter zope.exceptions.log.Formatter | |
path /home/user/app/var/log/client.log | |
</logfile> | |
<logfile> | |
formatter zope.exceptions.log.Formatter | |
path STDOUT | |
</logfile> | |
</eventlog> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment