[buildout]
extends = {{ template_runner_path }}
          {{ pbsready_export_template_path }}

parts +=
  nginx_conf
  nginx-launcher
  certificate-authority
  ca-nginx
  gunicorn-launcher
  gunicorn-graceful
  publish-connection-information
  slaprunner-promise
  apache-httpd-promise
  slaprunner-supervisord-wrapper
  runner-sshd-add-authorized-key
  runner-sshd-graceful
  runner-sshd-promise
  runner-sshkeys-authority
  runner-sshkeys-sshd
  runtestsuite
  symlinks
  shellinabox
  slapos-cfg
  cron-entry-prepare-software
  deploy-instance-parameters
  instance-software
  instance-software-type
  minishell-cwd
  bash-profile
  supervisord-wrapper
  supervisord-promise
  httpd-graceful-wrapper
## Monitoring part
## Monitor for runner
  monitor-base
  monitor-check-resilient-feed-file
  monitor-check-webrunner-internal-instance

[proxy-free-port]
recipe = slapos.cookbook:free_port
minimum = 49980
maximum = 49989
ip = ${slap-network-information:local-ipv4}

[runner-free-port]
recipe = slapos.cookbook:free_port
minimum = 50005
maximum = 50014
ip = ${slap-network-information:global-ipv6}

[slaprunner]
proxy_port = ${proxy-free-port:port}
runner_port = ${runner-free-port:port}

[supervisord-free-port]
recipe = slapos.cookbook:free_port
minimum = 39986
maximum = 39995
ip = ${slaprunner:ipv4}

[supervisord]
port = ${supervisord-free-port:port}

[exporter-configuration]
coreutils-location = {{ dumps(parameter_dict['coreutils-location']) }}
gawk-location = {{ dumps(parameter_dict['gawk-location']) }}

[exporter]
recipe = slapos.recipe.template:jinja2
template = {{ exporter_script_path }}
rendered = ${directory:bin}/${slap-parameter:namebase}-exporter
# backward compatibility for resilient stack
wrapper = ${:rendered}
mode = 700
context =
  section directory directory
  section parameter_dict exporter-configuration
  raw  output_log_file ${directory:log}/resilient.log
  raw  shell_binary {{ bash_executable_location }}
  raw  rsync_binary {{ rsync_executable_location }}

[monitor-httpd-free-port]
recipe = slapos.cookbook:free_port
minimum = 8437
maximum = 8446
ip = ${slap-network-information:global-ipv6}

[monitor-instance-parameter]
monitor-httpd-port = ${monitor-httpd-free-port:port}
# Pass some parameter to dispay in monitoring interface
instance-configuration =
  httpdcors cors-domain ${slaprunner-httpd-cors:location} ${httpd-graceful-wrapper:output}

# Extends publish section with resilient parameters
[publish-connection-information]
<= resilient-publish-connection-parameter

[monitor-check-resilient-feed-file]
recipe = slapos.recipe.template:jinja2
template = {{ monitor_check_resilient_feed_template_path }}
rendered = ${monitor-directory:reports}/check-create-resilient-feed-files
mode = 700
context =
  key input_feed_directory directory:notifier-feeds
  key monitor_feed_directory monitor-directory:public
  raw base_url http://[${notifier:host}]:${notifier:port}/get/
  raw python_executable ${buildout:executable}
