Commit 114984ab authored by Romain Courteaud's avatar Romain Courteaud

Allow to add squid in front of haproxy.

Add the "http-cache": True parameter in the backend json definition to activate.
parent ac24d00b
......@@ -7,6 +7,7 @@ Note: all port counters are pre-incremented. No idea why base port is skipped.
{% set zope_dummy_list = [] -%}
{% set current_apache_port = apache_port_base | int -%}
{% set current_haproxy_port = haproxy_port_base | int -%}
{% set current_squid_port = squid_port_base | int -%}
{% set json = json_module.loads(slapparameter_dict['json']) -%}
{% set bin_directory = parameter_dict['buildout-bin-directory'] -%}
{#
......@@ -366,6 +367,7 @@ context =
{% for backend_name, backend_configuration in json['backend'].iteritems() -%}
{% set haproxy_backend_list = [] -%}
{% set longrequest_logger = backend_configuration.get('longrequest-logger') -%}
{% set http_cache = backend_configuration.get('http-cache', False) -%}
{% for q in range(1, backend_configuration['zopecount'] + 1) -%}
{% set part_name = 'zope-%s-%s' % (backend_name, q) -%}
{% if longrequest_logger != None -%}
......@@ -389,6 +391,31 @@ context =
{% set scheme = backend_configuration.get('scheme', ['https']) -%}
{% set current_apache_port = current_apache_port + 2 -%}
{% set current_haproxy_port = current_haproxy_port + 1 -%}
{% set current_squid_port = current_squid_port + 1 -%}
{% set apache_rewrite_to = 'haproxy' -%}
{% if http_cache -%}
{% set apache_rewrite_to = 'squid' -%}
[{{ 'squid-' ~ backend_name ~ '-directory' }}]
recipe = slapos.cookbook:mkdirectory
cache-path = ${directory:var}/squid-{{ backend_name }}
[{{ section('squid-' ~ backend_name) }}]
recipe = slapos.cookbook:squid
prepare-path = ${directory:services}/squid-{{ backend_name }}-prepare
wrapper-path = ${directory:services}/squid-{{ backend_name }}
binary-path = {{ parameter_dict['squid'] }}/sbin/squid
conf-path = ${directory:etc}/squid-{{ backend_name }}.cfg
cache-path = ${squid-{{ backend_name }}-directory:cache-path}
ip = {{ ipv4 }}
port = {{ current_squid_port }}
backend-ip = ${haproxy-{{ backend_name }}:ip}
backend-port = ${haproxy-{{ backend_name }}:port}
access-log-path = ${directory:log}/squid-{{ backend_name }}-access.log
cache-log-path = ${directory:log}/squid-{{ backend_name }}-cache.log
pid-filename-path = ${directory:run}/squid-{{ backend_name }}.pid
{% endif -%}
{% if 'http' in scheme -%}
{% set section_name = 'apache-public-' ~ backend_name -%}
{% do publish_url_list.append(
......@@ -398,7 +425,7 @@ context =
}) -%}
[{{ section(section_name) }}]
recipe = slapos.cookbook:apache.zope.backend
backend = http://${haproxy-{{ backend_name }}:ip}:${haproxy-{{ backend_name }}:port}
backend = http://{{ '${' ~ apache_rewrite_to }}-{{ backend_name }}:ip}:{{ '${' ~ apache_rewrite_to }}-{{ backend_name }}:port}
ip = {{ ipv6 }}
port = {{ current_apache_port }}
scheme = http
......@@ -418,6 +445,8 @@ name = apache-public-{{ backend_name }}
log = ${apache-public-{{ backend_name }}:error-log} ${apache-public-{{ backend_name }}:access-log}
post = {{ bin_directory }}/killpidfromfile ${apache-public-{{ backend_name }}:pid-file} SIGUSR1
{% endif -%}
{% if 'https' in scheme -%}
{% set section_name = 'apache-' ~ backend_name -%}
{% do publish_url_list.append(
......@@ -427,7 +456,7 @@ post = {{ bin_directory }}/killpidfromfile ${apache-public-{{ backend_name }}:pi
}) -%}
[{{ section(section_name) }}]
recipe = slapos.cookbook:apache.zope.backend
backend = http://${haproxy-{{ backend_name }}:ip}:${haproxy-{{ backend_name }}:port}
backend = http://{{ '${' ~ apache_rewrite_to }}-{{ backend_name }}:ip}:{{ '${' ~ apache_rewrite_to }}-{{ backend_name }}:port}
ip = {{ ipv6 }}
port = {{ current_apache_port - 1 }}
wrapper = ${directory:bin}/apache-{{ backend_name }}
......
......@@ -28,6 +28,7 @@ context =
[dynamic-template-tidstorage-parameters]
apache = {{ apache_location }}
haproxy = {{ haproxy_location }}
squid = {{ squid_location }}
dcron = {{ dcron_location }}
logrotate = {{ logrotate_location }}
gzip = {{ gzip_location }}
......@@ -60,6 +61,7 @@ extra-context =
raw zope_port_base 12000
raw zeo_port_base 15000
raw haproxy_port_base 11000
raw squid_port_base 16000
raw apache_port_base 10000
key ipv4_set slap-parameters:ipv4
key ipv6_set slap-parameters:ipv6
......
......@@ -7,7 +7,8 @@ versions = versions
# Local development
develop =
${:parts-directory}/slapos.cookbook-repository
/opt/slapdev
# ${:parts-directory}/slapos.cookbook-repository
${:parts-directory}/cloudooo-repository
${:parts-directory}/vifib
......@@ -47,7 +48,7 @@ command = grep parts ${buildout:develop-eggs-directory}/slapos.core.egg-link
recipe = plone.recipe.command
stop-on-error = true
update-command = ${:command}
command = grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link
command = grep slapdev ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link
[slapos.cookbook-python2.6]
recipe = zc.recipe.egg
......@@ -120,7 +121,7 @@ extra-context =
[template-tidstorage]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/instance-tidstorage.cfg.in
md5sum = 0dbaee637c29d35b1a89216de898174d
md5sum = 1b85f3acc96f7bc9c699015c7cf4b719
mode = 640
[template-cloudooo]
......@@ -143,7 +144,7 @@ mode = 640
# XXX: "template.cfg" is hardcoded in instanciation recipe
filename = template.cfg
template = ${:_profile_base_location_}/instance.cfg.in
md5sum = ee7d9040f3f90948fe15f78196f66149
md5sum = 1e03a400cbdc543c3ae68078d061f2d6
extra-context =
key apache_location apache:location
key aspell_location aspell:location
......@@ -162,6 +163,7 @@ extra-context =
key grep_location grep:location
key gzip_location gzip:location
key haproxy_location haproxy:location
key squid_location squid:location
key imagemagick_location imagemagick:location
key libICE_location libICE:location
key libSM_location libSM:location
......
......@@ -83,6 +83,7 @@ extends =
../component/wget/buildout.cfg
../component/aspell/buildout.cfg
../component/cloudooo/buildout.cfg
../component/squid/buildout.cfg
versions = versions
......@@ -152,6 +153,7 @@ parts =
vifib-fix-products-paths
# some additional utils
slapos-toolbox
squid
[bt5-repository]
# Format:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment