<%=
require 'yaml'

bpm = {
  "processes" => [
    { "name" => "gorouter",
      "executable" => "/var/vcap/packages/gorouter/bin/gorouter",
      "args" => [ "-c", "/var/vcap/jobs/gorouter/config/gorouter.yml"],
      "limits" => {
        "open_files" =>  p("router.max_open_files")
      },
      "env" => {
        "GODEBUG" => "netdns=cgo"
      },
      "hooks" => {
          "pre_start" => "/var/vcap/jobs/gorouter/bin/bpm-pre-start"
      },
      "capabilities" => ["NET_BIND_SERVICE"]
    },
    { "name" => "gorouter-healthchecker",
      "executable" => "/var/vcap/packages/routing-healthchecker/bin/healthchecker",
      "args" => [ "-c", "/var/vcap/jobs/gorouter/config/healthchecker.yml"],
      "additional_volumes" => [
        { "path" => File.dirname(p('healthchecker.failure_counter_file')), "writable" => true}],
    }
  ]
}

if p('go.httplaxcontentlength') == true
      bpm['processes'][0]['env']['GODEBUG'] << ',httplaxcontentlength=1'
end

YAML.dump(bpm)
%>
