Skip to content

Commit

Permalink
Request consul in prestart hook
Browse files Browse the repository at this point in the history
  • Loading branch information
lens0021 committed Oct 4, 2024
1 parent 37aacb0 commit 9087d8e
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions jobs/fastcgi.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,23 @@ job "fastcgi" {
sidecar = false
}

driver = "exec"
driver = "docker"
config {
command = "sh"
image = "busybox:1.28"
command = "sh"
network_mode = "host"
args = [
"-c",
format(
"while ! ncat --send-only %s %s < /dev/null; do sleep 1; done",
local.main ? "127.0.0.1" : NOMAD_UPSTREAM_IP_mysql,
local.main ? "3306" : NOMAD_UPSTREAM_PORT_mysql
),
local.main ? "while ! ncat --send-only 127.0.0.1 3306 < /dev/null; do sleep 1; done"
: true ? "echo -n 'Waiting for service'; until -z ${var.main_nomad_addr} 3306 < /dev/null; do echo '.'; sleep 2; done"
: "echo -n 'Waiting for service'; until nslookup mysql.service.consul 127.0.0.1:8600 2>&1 >/dev/null; do echo '.'; sleep 2; done",
]
}

resources {
cpu = 100
memory = 100
}
}

task "wait-for-memcached" {
Expand All @@ -50,17 +55,24 @@ job "fastcgi" {
sidecar = false
}

driver = "exec"
driver = "docker"
config {
command = "sh"
image = "busybox:1.28"
command = "sh"
network_mode = "host"
args = [
"-c",
format("while ! ncat --send-only %s %s < /dev/null; do sleep 1; done",
local.main ? "127.0.0.1" : NOMAD_UPSTREAM_IP_memcached,
local.main ? "11211" : NOMAD_UPSTREAM_PORT_memcached
),
local.main ? format("while ! ncat --send-only %s %s < /dev/null; do sleep 1; done",
"127.0.0.1",
"11211"
) : "echo -n 'Waiting for service'; until nslookup memcached.service.consul 127.0.0.1:8600 2>&1 >/dev/null; do echo '.'; sleep 2; done",
]
}

resources {
cpu = 100
memory = 100
}
}

task "fastcgi" {
Expand Down

0 comments on commit 9087d8e

Please sign in to comment.