common/templates/task.wait_for

38 lines
952 B
Plaintext

[[ if and (has . "wait_for") (gt (len .wait_for) 0) -]]
# wait for required services tp be ready before starting the main task
task "wait-for" {
driver = "docker"
user = 1053
config {
image = "[[ .docker.repo ]][[ .docker.base_images.wait_for.image ]]"
readonly_rootfs = true
pids_limit = 20
}
lifecycle {
hook = "prestart"
}
env {
[[- range $idx, $service := .wait_for ]]
[[- if $service.service | regexp.Match "\\.$" ]]
SERVICE_[[ $idx ]] = [[ $service.service | toJSON ]]
[[- else ]]
SERVICE_[[ $idx ]] = [[ printf "%s%s.service.%s" $service.service $.consul.suffix $.consul.domain | toJSON ]]
[[- end ]]
[[- if has $service "count" ]]
COUNT_[[ $idx ]] = [[ $service.count ]]
[[- end ]]
[[- end ]]
}
resources {
cpu = 10
memory = 10
memory_max = 30
}
}
[[ end ]]