[buildout]
parts =
  dream-simulation
  dream-platform
  dream-test-suite
  dream-interpreter
  grunt-watch
  publish-connection-parameter
  dream-platform-url-available

eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
extends = ${monitor-template:output}

# parameters
[instance-parameter]
recipe = slapos.cookbook:slapconfiguration
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}

[dream-platform-parameter]
port = 18080
host = $${instance-parameter:ipv6-random}
url = http://[$${:host}]:$${:port}

# interpreter
[dream-interpreter]
recipe = slapos.cookbook:wrapper
command-line = ${buildout:bin-directory}/dream_interpreter
wrapper-path = $${buildout:bin-directory}/dream_interpreter

# service
[dream-platform]
recipe = slapos.cookbook:wrapper
command-line = ${buildout:bin-directory}/dream_platform --debug --host $${dream-platform-parameter:host} --port $${dream-platform-parameter:port} --log $${directory:log}/dream_platform.log
wrapper-path = $${directory:service}/dream_platform

[dream-platform-url-available]
<= monitor-promise-base
promise = check_url_available
name = $${:_buildout_section_name_}.py
config-url=  $${dream-platform-parameter:url}


[grunt-watch]
recipe = slapos.cookbook:wrapper
command-line = bash -c 'cd ${dream-repository.git:location}; PATH=${nodejs:location}/bin/:$PATH ${dream-repository.git:location}/node_modules/grunt-cli/bin/grunt watch -f > $${directory:log}/grunt.log'
wrapper-path = $${directory:service}/dream_grunt_watch

# CLI
[dream-simulation]
recipe = slapos.cookbook:wrapper
command-line = ${buildout:bin-directory}/dream_simulation
wrapper-path = $${directory:script}/dream_simulation

[dream-test-suite]
recipe = slapos.cookbook:wrapper
command-line = ${dream-testrunner:script}
wrapper-path = $${directory:script}/dream_test_suite

[directory]
recipe = slapos.cookbook:mkdirectory
home = $${buildout:directory}
etc = $${:home}/etc
var = $${:home}/var
script = $${:etc}/run/
service = $${:etc}/service
promise = $${:etc}/promise/
log = $${:var}/log

[publish-connection-parameter]
recipe = slapos.cookbook:publishurl
url = $${dream-platform-parameter:url}
