#############################
#
# Instanciate haproxy
#
# haproxy-id -- local id of the requested haproxy (login, web,...)
#
# haproxy-port -- ip port to use to run the process
#
# maxconn -- max connection per server
#
# site-id -- ID of the ERP5 site object in ZODB
#
# storage_list -- string with list of all resquested storage
#    Example: event_module person_module
#
#############################
[buildout]
parts =
  haproxy-instance
  publish-haproxy-connection-information

eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true

[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/

[basedirectory]
recipe = slapos.cookbook:mkdirectory
services = $${rootdirectory:etc}/run/

[haproxy-instance]
recipe = slapos.cookbook:haproxy
name = $${slap-parameter:haproxy-id}
conf-path = $${rootdirectory:etc}/haproxy-$${slap-parameter:haproxy-id}.cfg
ip = $${slap-network-information:local-ipv4}
port = $${slap-parameter:haproxy-port}
maxconn = $${slap-parameter:maxconn}
server-check-path = /$${slap-parameter:site-id}/getId

wrapper-path = $${basedirectory:services}/haproxy_$${slap-parameter:haproxy-id}
binary-path = ${memcached:location}/bin/memcached

[publish-haproxy-connection-information]
recipe = slapos.cookbook:publishurl
url = http://$${haproxy-instance:ip}:$${haproxy-instance:port}/