[buildout]
parts =
  postgres-urlparse
  apacheperl-promise
  publish-connection-information
  mioga-instance

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

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

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

[apacheperl-instance]
recipe = slapos.cookbook:apacheperl
ip = $${slap-network-information:global-ipv6}
port = 8080
httpd-binary = ${apache-2.2:location}/bin/httpd
# XXX TODO: Wait for the iso to be uploaded (execute_wait)
path = $${basedirectory:services}/apacheperl
htdocs = $${basedirectory:htdocs}
httpd-conf = $${rootdirectory:etc}/httpd.conf
pid-file = $${basedirectory:services}/apache.pid
lock-file = $${basedirectory:services}/apache.lock
wrapper = $${basedirectory:services}/httpd_wrapper
# source = ${buildout:parts-directory}/${:_buildout_section_name_}
error-log = $${rootdirectory:log}/error.log
access-log = $${rootdirectory:log}/access.log

[apacheperl-promise]
recipe = slapos.cookbook:check_port_listening
path = $${basedirectory:promises}/httpd_promise
hostname = $${apacheperl-instance:ip}
port = $${apacheperl-instance:port}

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

# Request Postgres instance and parse its URL
[request-postgres]
<= slap-connection
recipe = slapos.cookbook:request
name = Postgres
software-url = $${slap-connection:software-release-url}
software-type = postgres
return = url
sla = computer_guid
sla-computer_guid = $${slap-connection:computer-id}

[postgres-urlparse]
recipe = slapos.cookbook:urlparse
url = $${request-postgres:connection-url}

[symlinks]
recipe = cns.recipe.symlink
symlink_target = $${rootdirectory:bin}
symlink_base = ${postgresql:location}/bin

[mioga-instance]
recipe = slapos.cookbook:mioga.instantiate
mioga_compile_dir = ${template-apacheperl:compile-directory}
# Pity that the following line does not work. Or does it?
# mioga_compile_env = ${mioga:environment}
mioga_add_to_path = ${libxslt:location}/bin:${libxml2:location}/bin
var_directory = $${rootdirectory:var}
instance_root = $${buildout:directory}
perl_bin = ${perl:location}/bin
postgres_bin = ${postgresql:location}/bin
htdocs = $${apacheperl-instance:htdocs}
db_host = $${postgres-urlparse:host}
db_port = $${postgres-urlparse:port}
db_dbname = $${postgres-urlparse:path}
db_username = $${postgres-urlparse:username}
db_password = $${postgres-urlparse:password}